systemctl completions: Add reset-failed completion

Fixes #3153.
This commit is contained in:
Fabian Homborg 2016-06-21 12:43:50 +02:00
parent 3a0d417b9e
commit d66d51f101

View file

@ -23,6 +23,15 @@ function __fish_systemd_properties
end
end
function __fish_systemctl_failed
if __fish_contains_opt user
# Without arguments, no "--type=" will be passed
systemctl --user list-units --state=failed --no-legend --type=$argv ^/dev/null | cut -f 1 -d ' '
else
systemctl list-units --state=failed --no-legend --type=$argv ^/dev/null | cut -f 1 -d ' '
end
end
complete -f -e -c systemctl
# All systemctl commands
complete -f -c systemctl -n "not __fish_seen_subcommand_from $commands" -a "$commands"
@ -42,6 +51,9 @@ for command in start stop restart try-restart reload-or-restart reload-or-try-re
end
end
# Handle reset-failed specially because it doesn't apply to unit-files (only units that have been tried can have failed) and a second "--state=" argument doesn't override the earlier one.
complete -f -c systemctl -n "__fish_seen_subcommand_from reset-failed" -a "(__fish_systemctl_failed)"
# Enable/Disable: Only show units with matching state
for t in services sockets timers service_paths
complete -f -c systemctl -n "__fish_seen_subcommand_from enable" -a "(eval __fish_systemctl_$t --state=disabled)"