fork/fish-shell

git clone https://git.julia.blue/fork/fish-shell

metamuffinwg completion5648c86a0

master
3.6 KiB45 linesraw
1set -l commands show showconf set setconf addconf syncconf genkey genpsk pubkey
2
3function __fish_wg_print_interfaces
4    wg show interfaces | string split ' '
5end
6
7# disable file completions
8complete -c wg -f
9
10# subcommands
11complete -c wg -n "not __fish_seen_subcommand_from $commands" -x -a "$commands"
12complete -c wg -n "not __fish_seen_subcommand_from $commands" -a show -d "Shows the current configuration and device information"
13complete -c wg -n "not __fish_seen_subcommand_from $commands" -a showconf -d "Shows the current configuration of an interface"
14complete -c wg -n "not __fish_seen_subcommand_from $commands" -a set -d "Change the current configuration"
15complete -c wg -n "not __fish_seen_subcommand_from $commands" -a setconf -d "Applies a configuration to an interface"
16complete -c wg -n "not __fish_seen_subcommand_from $commands" -a addconf -d "Appends a configuration to an interface"
17complete -c wg -n "not __fish_seen_subcommand_from $commands" -a syncconf -d "Synchronizes a configuration to an interface"
18complete -c wg -n "not __fish_seen_subcommand_from $commands" -a genkey -d "Generates a new private key"
19complete -c wg -n "not __fish_seen_subcommand_from $commands" -a genpsk -d "Generates a new preshared key"
20complete -c wg -n "not __fish_seen_subcommand_from $commands" -a pubkey -d "Computes public key given a private key"
21
22complete -c wg -n "__fish_seen_subcommand_from $commands" -x -l help -d 'View usage of the subcommand'
23
24complete -c wg -n "__fish_seen_subcommand_from addconf syncconf setconf; and __fish_is_nth_token 2" -f -a "(__fish_wg_print_interfaces)" -d 'Wireguard Interface'
25complete -c wg -n "__fish_seen_subcommand_from addconf syncconf setconf; and __fish_is_nth_token 3" -F -d "Configuration file"
26
27complete -c wg -n "__fish_seen_subcommand_from showconf; and __fish_is_nth_token 2" -f -a "(__fish_wg_print_interfaces)" -d 'Wireguard Interface'
28
29complete -c wg -n "__fish_seen_subcommand_from show; and __fish_is_nth_token 2" -x -a interfaces -d "Shows a list of interfaces"
30complete -c wg -n "__fish_seen_subcommand_from show; and __fish_is_nth_token 2" -f -a all -d "Shows information for all interfaces"
31complete -c wg -n "__fish_seen_subcommand_from show; and __fish_is_nth_token 2" -f -a "(__fish_wg_print_interfaces)" -d 'Wireguard Interface'
32complete -c wg -n "__fish_seen_subcommand_from show; and __fish_is_nth_token 3" -f -a "public-key private-key listen-port fwmark peers preshared-keys endpoints allowed-ips latest-handshakes transfer persistent-keepalive dump"
33
34set -l settables fwmark private peer peer endpoint persistent allowed
35set -l settables_kw $settables[..] remove preshared-key
36complete -c wg -n "__fish_seen_subcommand_from set; and __fish_is_nth_token 2" -f -a "(__fish_wg_print_interfaces)" -d 'Wireguard Interface'
37complete -c wg -n "__fish_seen_subcommand_from set; and not __fish_prev_arg_in $settables_kw; and not __fish_is_nth_token 2" -f -a "$settables"
38complete -c wg -n "__fish_seen_subcommand_from set; and __fish_prev_arg_in fwmark" -F
39complete -c wg -n "__fish_seen_subcommand_from set; and __fish_prev_arg_in private-key" -F
40complete -c wg -n "__fish_seen_subcommand_from set; and __fish_prev_arg_in peer" -a 'remove preshared key'
41complete -c wg -n "__fish_seen_subcommand_from set; and __fish_prev_arg_in preshared-key" -F
42complete -c wg -n "__fish_seen_subcommand_from set; and __fish_prev_arg_in remove" -F
43complete -c wg -n "__fish_seen_subcommand_from set; and __fish_prev_arg_in endpoint"
44complete -c wg -n "__fish_seen_subcommand_from set; and __fish_prev_arg_in persistent-keepalive"
45complete -c wg -n "__fish_seen_subcommand_from set; and __fish_prev_arg_in allowed-ips"