aboutsummaryrefslogtreecommitdiffhomepage
path: root/share/completions/lunchy.fish
blob: ea1538b6fc197058fc9e9f3882fd9cce30d8c57e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
function __fish_lunchy_needs_command
  set cmd (commandline -opc)

  if test (count $cmd) -eq 1
    return 0
  end

  return 1
end

function __fish_lunchy_using_command
  set cmd (commandline -opc)
  set cmd_count (count $cmd)

  if test $cmd_count -lt 2
    return 1
  end

  for arg in $argv
    if test $arg = $cmd[2]
      return 0
    end
  end

  return 1
end

complete -f -c lunchy -s v -l verbose -d 'Show command executions'

# Commands
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'

# Commands with service completion
complete -f -c lunchy -n '__fish_lunchy_using_command ls list start stop restart status edit' -a '(lunchy ls)' -d 'Service'

# 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'