2013-05-26 07:41:33 +08:00
|
|
|
function __fish_lunchy_needs_command
|
2020-05-15 13:56:06 +08:00
|
|
|
set -l cmd (commandline -opc)
|
2013-05-26 07:41:33 +08:00
|
|
|
|
2019-05-05 18:53:09 +08:00
|
|
|
if test (count $cmd) -eq 1
|
|
|
|
return 0
|
|
|
|
end
|
2013-05-26 07:41:33 +08:00
|
|
|
|
2019-05-05 18:53:09 +08:00
|
|
|
return 1
|
2013-05-26 07:41:33 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
function __fish_lunchy_using_command
|
2020-05-15 13:56:06 +08:00
|
|
|
set -l cmd (commandline -opc)
|
|
|
|
set -l cmd_count (count $cmd)
|
2013-05-26 07:41:33 +08:00
|
|
|
|
2019-05-05 18:53:09 +08:00
|
|
|
if test $cmd_count -lt 2
|
|
|
|
return 1
|
|
|
|
end
|
2013-05-26 07:41:33 +08:00
|
|
|
|
2019-05-05 18:53:09 +08:00
|
|
|
for arg in $argv
|
|
|
|
if test $arg = $cmd[2]
|
|
|
|
return 0
|
|
|
|
end
|
2013-05-26 07:41:33 +08:00
|
|
|
end
|
|
|
|
|
2019-05-05 18:53:09 +08:00
|
|
|
return 1
|
2013-05-26 07:41:33 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
complete -f -c lunchy -s v -l verbose -d 'Show command executions'
|
|
|
|
|
|
|
|
# Commands
|
2020-03-10 02:36:12 +08:00
|
|
|
complete -f -c lunchy -n __fish_lunchy_needs_command -a install -d 'Installs [file] to ~/Library/LaunchAgents or /Library/LaunchAgents'
|
|
|
|
complete -f -c lunchy -n __fish_lunchy_needs_command -a 'ls list' -d 'Show the list of installed agents'
|
|
|
|
complete -f -c lunchy -n __fish_lunchy_needs_command -a start -d 'Start the first matching agent'
|
|
|
|
complete -f -c lunchy -n __fish_lunchy_needs_command -a stop -d 'Stop the first matching agent'
|
|
|
|
complete -f -c lunchy -n __fish_lunchy_needs_command -a restart -d 'Stop and start the first matching agent'
|
|
|
|
complete -f -c lunchy -n __fish_lunchy_needs_command -a status -d 'Show the PID and label for all agents'
|
|
|
|
complete -f -c lunchy -n __fish_lunchy_needs_command -a edit -d 'Opens the launchctl daemon file in the default editor'
|
2013-05-26 07:41:33 +08:00
|
|
|
|
|
|
|
# Commands with service completion
|
2020-03-10 02:36:12 +08:00
|
|
|
complete -f -c lunchy -n '__fish_lunchy_using_command ls list start stop restart status edit' -a '(lunchy ls)' -d Service
|
2013-05-26 07:41:33 +08:00
|
|
|
|
|
|
|
# Command: start
|
|
|
|
complete -f -c lunchy -n '__fish_lunchy_using_command start' -s w -l write -d 'Persist command'
|
|
|
|
complete -f -c lunchy -n '__fish_lunchy_using_command start' -s F -l force -d 'Force start (disabled) agents'
|
|
|
|
|
|
|
|
# Command: stop
|
|
|
|
complete -f -c lunchy -n '__fish_lunchy_using_command stop' -s w -l write -d 'Persist command'
|