From fb1443a8853f2c2d0cbe3b5b0f33c76e704993c4 Mon Sep 17 00:00:00 2001 From: Fabian Homborg Date: Sat, 30 Apr 2016 16:51:49 +0200 Subject: [PATCH] Remove using_command from netctl completions This allows `; and netctl` to work. First step towards #2705. --- share/completions/netctl.fish | 61 +++++++++-------------------------- 1 file changed, 16 insertions(+), 45 deletions(-) diff --git a/share/completions/netctl.fish b/share/completions/netctl.fish index ac5c07b57..46d9d8435 100644 --- a/share/completions/netctl.fish +++ b/share/completions/netctl.fish @@ -1,20 +1,4 @@ -function __fish_netctl_needs_command - set cmd (commandline -opc) - if [ (count $cmd) -eq 1 ] - return 0 - end - return 1 -end - -function __fish_netctl_using_command - set cmd (commandline -opc) - if [ (count $cmd) -gt 1 ] - if [ $argv[1] = $cmd[2] ] - return 0 - end - end - return 1 -end +set -l cmds list store restore stop-all start stop restart switch-to status enable disable reenable is-enabled edit function __fish_netctl_get_profiles command netctl list | sed -e 's/^[ \t*]*//' @@ -22,31 +6,18 @@ end complete -f -c netctl -l help -d 'Display help' complete -f -c netctl -l version -d 'Display version' -complete -f -c netctl -n '__fish_netctl_needs_command' -a list -d 'List available profiles' -complete -f -c netctl -n '__fish_netctl_needs_command' -a store -d 'Save which profiles are active' -complete -f -c netctl -n '__fish_netctl_needs_command' -a restore -d 'Load saved profiles' -complete -f -c netctl -n '__fish_netctl_needs_command' -a stop-all -d 'Stops all profiles' - -complete -f -c netctl -n '__fish_netctl_needs_command' -a start -d 'Start a profile' -complete -f -c netctl -n '__fish_netctl_using_command start' -a '(__fish_netctl_get_profiles)' -d 'Profile' - -complete -f -c netctl -n '__fish_netctl_needs_command' -a stop -d 'Stop a profile' -complete -f -c netctl -n '__fish_netctl_using_command stop' -a '(__fish_netctl_get_profiles)' -d 'Profile' - -complete -f -c netctl -n '__fish_netctl_needs_command' -a restart -d 'Restart a profile' -complete -f -c netctl -n '__fish_netctl_using_command restart' -a '(__fish_netctl_get_profiles)' -d 'Profile' - -complete -f -c netctl -n '__fish_netctl_needs_command' -a switch-to -d 'Switch to a profile' -complete -f -c netctl -n '__fish_netctl_using_command switch-to' -a '(__fish_netctl_get_profiles)' -d 'Profile' - -complete -f -c netctl -n '__fish_netctl_needs_command' -a status -d 'Show runtime status of a profile' -complete -f -c netctl -n '__fish_netctl_using_command status' -a '(__fish_netctl_get_profiles)' -d 'Profile' - -complete -f -c netctl -n '__fish_netctl_needs_command' -a enable -d 'Enable the systemd unit for a profile' -complete -f -c netctl -n '__fish_netctl_using_command enable' -a '(__fish_netctl_get_profiles)' -d 'Profile' - -complete -f -c netctl -n '__fish_netctl_needs_command' -a disable -d 'Disable the systemd unit for a profile' -complete -f -c netctl -n '__fish_netctl_using_command disable' -a '(__fish_netctl_get_profiles)' -d 'Profile' - -complete -f -c netctl -n '__fish_netctl_needs_command' -a reenable -d 'Reenable the systemd unit for a profile' -complete -f -c netctl -n '__fish_netctl_using_command reenable' -a '(__fish_netctl_get_profiles)' -d 'Profile' +complete -f -c netctl -n "not __fish_seen_subcommand_from $cmds" -a list -d 'List available profiles' +complete -f -c netctl -n "not __fish_seen_subcommand_from $cmds" -a store -d 'Save which profiles are active' +complete -f -c netctl -n "not __fish_seen_subcommand_from $cmds" -a restore -d 'Load saved profiles' +complete -f -c netctl -n "not __fish_seen_subcommand_from $cmds" -a stop-all -d 'Stops all profiles' +complete -f -c netctl -n "not __fish_seen_subcommand_from $cmds" -a start -d 'Start a profile' +complete -f -c netctl -n "not __fish_seen_subcommand_from $cmds" -a stop -d 'Stop a profile' +complete -f -c netctl -n "not __fish_seen_subcommand_from $cmds" -a restart -d 'Restart a profile' +complete -f -c netctl -n "not __fish_seen_subcommand_from $cmds" -a switch-to -d 'Switch to a profile' +complete -f -c netctl -n "not __fish_seen_subcommand_from $cmds" -a status -d 'Show runtime status of a profile' +complete -f -c netctl -n "not __fish_seen_subcommand_from $cmds" -a enable -d 'Enable the systemd unit for a profile' +complete -f -c netctl -n "not __fish_seen_subcommand_from $cmds" -a disable -d 'Disable the systemd unit for a profile' +complete -f -c netctl -n "not __fish_seen_subcommand_from $cmds" -a reenable -d 'Reenable the systemd unit for a profile' +complete -f -c netctl -n "not __fish_seen_subcommand_from $cmds" -a is-enabled -d 'Check whether the unit is enabled' +complete -f -c netctl -n "not __fish_seen_subcommand_from $cmds" -a edit -d 'Open the specified profile in an editor' +complete -f -c netctl -n "__fish_seen_subcommand_from start stop restart switch-to status enable disable reenable is-enabled edit" -a '(__fish_netctl_get_profiles)' -d 'Profile'