diff options
author | Fabian Homborg <FHomborg@gmail.com> | 2015-02-19 15:44:17 +0100 |
---|---|---|
committer | ridiculousfish <corydoras@ridiculousfish.com> | 2015-03-06 23:05:24 -0800 |
commit | 3d163eb9101257527e023267d5b27b7018a972e4 (patch) | |
tree | 6edf2ce545eadc656a76cf3939d40220e651d3c1 /share | |
parent | 3e32715693878548f2cf51206e33ebf6f0dda47b (diff) |
systemctl completions: Simplify code by using __fish_seen_subcommand_from
Diffstat (limited to 'share')
-rw-r--r-- | share/completions/systemctl.fish | 84 |
1 files changed, 32 insertions, 52 deletions
diff --git a/share/completions/systemctl.fish b/share/completions/systemctl.fish index bcb11a95..e8b8c2da 100644 --- a/share/completions/systemctl.fish +++ b/share/completions/systemctl.fish @@ -1,69 +1,49 @@ - -function __fish_systemctl_using_command - set cmd (commandline -opc) - if [ (count $cmd) -gt 1 ] - if contains -- $argv $cmd - return 0 - end - end - return 1 -end - -function __fish_systemctl_has_no_command - set cmd (commandline -opc) - set commands list-units list-sockets start stop reload restart try-restart reload-or-restart reload-or-try-restart \ +set -l commands list-units list-sockets start stop reload restart try-restart reload-or-restart reload-or-try-restart \ isolate kill is-active is-failed status show get-cgroup-attr set-cgroup-attr unset-cgroup-attr set-cgroup help \ reset-failed list-unit-files enable disable is-enabled reenable preset mask unmask link load list-jobs cancel dump \ list-dependencies snapshot delete daemon-reload daemon-reexec show show-environment set-environment unset-environment \ default rescue emergency halt poweroff reboot kexec exit suspend hibernate hybrid-sleep switch-root - for word in $cmd - if contains -- $word $commands - return 1 - end - end - return 0 -end # All systemctl commands -complete -f -c systemctl -n "test (count (commandline -poc)) = 1" -a 'list-units list-sockets start stop reload restart try-restart reload-or-restart reload-or-try-restart isolate kill is-active is-failed status show get-cgroup-attr set-cgroup-attr unset-cgroup-attr set-cgroup help reset-failed list-unit-files enable disable is-enabled reenable preset mask unmask link load list-jobs cancel dump list-dependencies snapshot delete daemon-reload daemon-reexec show show-environment set-environment unset-environment default rescue emergency halt poweroff reboot kexec exit suspend hibernate hybrid-sleep switch-root' +complete -f -c systemctl -n "not __fish_seen_subcommand_from $commands" -a 'list-units list-sockets start stop reload restart try-restart reload-or-restart reload-or-try-restart isolate kill is-active is-failed status show get-cgroup-attr set-cgroup-attr unset-cgroup-attr set-cgroup help reset-failed list-unit-files enable disable is-enabled reenable preset mask unmask link load list-jobs cancel dump list-dependencies snapshot delete daemon-reload daemon-reexec show show-environment set-environment unset-environment default rescue emergency halt poweroff reboot kexec exit suspend hibernate hybrid-sleep switch-root' #### Units commands # Start -complete -f -c systemctl -n "__fish_systemctl_has_no_command" -a start -d 'Start one or more units' -complete -f -c systemctl -n '__fish_systemctl_using_command start' -a '(__fish_systemctl_services)' -d 'Service' -complete -f -c systemctl -n '__fish_systemctl_using_command start' -a '(__fish_systemctl_sockets)' -d 'Socket' -complete -f -c systemctl -n '__fish_systemctl_using_command start' -a '(__fish_systemctl_mounts)' -d 'Mount' -complete -f -c systemctl -n '__fish_systemctl_using_command start' -a '(__fish_systemctl_service_paths)' -d 'Path' +complete -f -c systemctl -n "not __fish_seen_subcommand_from $commands" -a start -d 'Start one or more units' +complete -f -c systemctl -n '__fish_seen_subcommand_from start' -a '(__fish_systemctl_services)' -d 'Service' +complete -f -c systemctl -n '__fish_seen_subcommand_from start' -a '(__fish_systemctl_sockets)' -d 'Socket' +complete -f -c systemctl -n '__fish_seen_subcommand_from start' -a '(__fish_systemctl_mounts)' -d 'Mount' +complete -f -c systemctl -n '__fish_seen_subcommand_from start' -a '(__fish_systemctl_service_paths)' -d 'Path' # Stop -complete -f -c systemctl -n "__fish_systemctl_has_no_command" -a stop -d 'Stop one or more units' -complete -f -c systemctl -n '__fish_systemctl_using_command stop' -a '(__fish_systemctl_services)' -d 'Service' -complete -f -c systemctl -n '__fish_systemctl_using_command stop' -a '(__fish_systemctl_sockets)' -d 'Socket' -complete -f -c systemctl -n '__fish_systemctl_using_command stop' -a '(__fish_systemctl_mounts)' -d 'Mount' -complete -f -c systemctl -n '__fish_systemctl_using_command stop' -a '(__fish_systemctl_service_paths)' -d 'Path' +complete -f -c systemctl -n "not __fish_seen_subcommand_from $commands" -a stop -d 'Stop one or more units' +complete -f -c systemctl -n '__fish_seen_subcommand_from stop' -a '(__fish_systemctl_services)' -d 'Service' +complete -f -c systemctl -n '__fish_seen_subcommand_from stop' -a '(__fish_systemctl_sockets)' -d 'Socket' +complete -f -c systemctl -n '__fish_seen_subcommand_from stop' -a '(__fish_systemctl_mounts)' -d 'Mount' +complete -f -c systemctl -n '__fish_seen_subcommand_from stop' -a '(__fish_systemctl_service_paths)' -d 'Path' # Restart -complete -f -c systemctl -n "__fish_systemctl_has_no_command" -a restart -d 'Restart one or more units' -complete -f -c systemctl -n '__fish_systemctl_using_command restart' -a '(__fish_systemctl_services)' -d 'Service' -complete -f -c systemctl -n '__fish_systemctl_using_command restart' -a '(__fish_systemctl_sockets)' -d 'Socket' -complete -f -c systemctl -n '__fish_systemctl_using_command restart' -a '(__fish_systemctl_mounts)' -d 'Mount' -complete -f -c systemctl -n '__fish_systemctl_using_command restart' -a '(__fish_systemctl_service_paths)' -d 'Path' +complete -f -c systemctl -n "not __fish_seen_subcommand_from $commands" -a restart -d 'Restart one or more units' +complete -f -c systemctl -n '__fish_seen_subcommand_from restart' -a '(__fish_systemctl_services)' -d 'Service' +complete -f -c systemctl -n '__fish_seen_subcommand_from restart' -a '(__fish_systemctl_sockets)' -d 'Socket' +complete -f -c systemctl -n '__fish_seen_subcommand_from restart' -a '(__fish_systemctl_mounts)' -d 'Mount' +complete -f -c systemctl -n '__fish_seen_subcommand_from restart' -a '(__fish_systemctl_service_paths)' -d 'Path' # Status -complete -f -c systemctl -n "__fish_systemctl_has_no_command" -a status -d 'Runtime status about one or more units' -complete -f -c systemctl -n '__fish_systemctl_using_command status' -a '(__fish_systemctl_services)' -d 'Service' -complete -f -c systemctl -n '__fish_systemctl_using_command status' -a '(__fish_systemctl_sockets)' -d 'Socket' -complete -f -c systemctl -n '__fish_systemctl_using_command status' -a '(__fish_systemctl_mounts)' -d 'Mount' -complete -f -c systemctl -n '__fish_systemctl_using_command status' -a '(__fish_systemctl_service_paths)' -d 'Path' +complete -f -c systemctl -n "not __fish_seen_subcommand_from $commands" -a status -d 'Runtime status about one or more units' +complete -f -c systemctl -n '__fish_seen_subcommand_from status' -a '(__fish_systemctl_services)' -d 'Service' +complete -f -c systemctl -n '__fish_seen_subcommand_from status' -a '(__fish_systemctl_sockets)' -d 'Socket' +complete -f -c systemctl -n '__fish_seen_subcommand_from status' -a '(__fish_systemctl_mounts)' -d 'Mount' +complete -f -c systemctl -n '__fish_seen_subcommand_from status' -a '(__fish_systemctl_service_paths)' -d 'Path' # Enable -complete -f -c systemctl -n "__fish_systemctl_has_no_command" -a enable -d 'Enable one or more units' -complete -f -c systemctl -n '__fish_systemctl_using_command enable' -a '(__fish_systemctl_services)' -d 'Service' -complete -f -c systemctl -n '__fish_systemctl_using_command enable' -a '(__fish_systemctl_sockets)' -d 'Socket' -complete -f -c systemctl -n '__fish_systemctl_using_command enable' -a '(__fish_systemctl_mounts)' -d 'Mount' -complete -f -c systemctl -n '__fish_systemctl_using_command enable' -a '(__fish_systemctl_service_paths)' -d 'Path' +complete -f -c systemctl -n "not __fish_seen_subcommand_from $commands" -a enable -d 'Enable one or more units' +complete -f -c systemctl -n '__fish_seen_subcommand_from enable' -a '(__fish_systemctl_services)' -d 'Service' +complete -f -c systemctl -n '__fish_seen_subcommand_from enable' -a '(__fish_systemctl_sockets)' -d 'Socket' +complete -f -c systemctl -n '__fish_seen_subcommand_from enable' -a '(__fish_systemctl_mounts)' -d 'Mount' +complete -f -c systemctl -n '__fish_seen_subcommand_from enable' -a '(__fish_systemctl_service_paths)' -d 'Path' # Disable -complete -f -c systemctl -n "__fish_systemctl_has_no_command" -a disable -d 'Disable one or more units' -complete -f -c systemctl -n '__fish_systemctl_using_command disable' -a '(__fish_systemctl_services)' -d 'Service' -complete -f -c systemctl -n '__fish_systemctl_using_command disable' -a '(__fish_systemctl_sockets)' -d 'Socket' -complete -f -c systemctl -n '__fish_systemctl_using_command disable' -a '(__fish_systemctl_mounts)' -d 'Mount' -complete -f -c systemctl -n '__fish_systemctl_using_command disable' -a '(__fish_systemctl_service_paths)' -d 'Path' +complete -f -c systemctl -n "not __fish_seen_subcommand_from $commands" -a disable -d 'Disable one or more units' +complete -f -c systemctl -n '__fish_seen_subcommand_from disable' -a '(__fish_systemctl_services)' -d 'Service' +complete -f -c systemctl -n '__fish_seen_subcommand_from disable' -a '(__fish_systemctl_sockets)' -d 'Socket' +complete -f -c systemctl -n '__fish_seen_subcommand_from disable' -a '(__fish_systemctl_mounts)' -d 'Mount' +complete -f -c systemctl -n '__fish_seen_subcommand_from disable' -a '(__fish_systemctl_service_paths)' -d 'Path' complete -c systemctl -s t -l type -d 'List of unit types' -xa 'help service, mount, socket, target,' complete -c systemctl -l state -d 'List of unit states' -xa 'LOAD, SUB, ACTIVE,' complete -c systemctl -s p -l property -d 'Properties displayed in the "show" command' |