nixos-firewall-tool: add shell completions for bash and fish
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
_nixos_firewall_tool() {
|
||||
case "${COMP_CWORD}" in
|
||||
1)
|
||||
COMPREPLY=($(compgen -W "open show reset" -- "${COMP_WORDS[1]}"))
|
||||
;;
|
||||
2)
|
||||
case "${COMP_WORDS[1]}" in
|
||||
"open")
|
||||
COMPREPLY=($(compgen -W "tcp udp" -- "${COMP_WORDS[2]}"))
|
||||
;;
|
||||
*)
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
*)
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
complete -F _nixos_firewall_tool nixos-firewall-tool
|
||||
@@ -0,0 +1,5 @@
|
||||
complete -c nixos-firewall-tool -f
|
||||
complete -c nixos-firewall-tool -k -a reset -d 'Reset firewall configuration to system settings' -n "__fish_is_first_token"
|
||||
complete -c nixos-firewall-tool -k -a show -d 'Show all firewall rules' -n "__fish_is_first_token"
|
||||
complete -c nixos-firewall-tool -k -a open -d 'Open a port temporarily' -n "__fish_is_first_token"
|
||||
complete -c nixos-firewall-tool -k -a "tcp udp" -n "__fish_seen_subcommand_from open && __fish_is_nth_token 2"
|
||||
@@ -24,6 +24,7 @@ stdenvNoCC.mkDerivation rec {
|
||||
|
||||
installPhase = ''
|
||||
installBin nixos-firewall-tool
|
||||
installShellCompletion nixos-firewall-tool.{bash,fish}
|
||||
'';
|
||||
|
||||
# Skip shellcheck if GHC is not available, see writeShellApplication.
|
||||
|
||||
Reference in New Issue
Block a user