From b6c5f3dc3842a41d6330df882b1acbdf9bb4c699 Mon Sep 17 00:00:00 2001 From: exploide Date: Sat, 12 Apr 2025 16:26:15 +0200 Subject: [PATCH] completions: improved ip completions added completions for ip tuntap standardize help completion --- share/completions/ip.fish | 42 ++++++++++++++++++++++++++++++++------- 1 file changed, 35 insertions(+), 7 deletions(-) diff --git a/share/completions/ip.fish b/share/completions/ip.fish index 5e47170cf..2faf39b70 100644 --- a/share/completions/ip.fish +++ b/share/completions/ip.fish @@ -260,10 +260,12 @@ function __fish_complete_ip case address # We're still _on_ the second word, which is the subcommand if not set -q cmd[3] - printf '%s\t%s\n' add "Add new protocol address" \ + printf '%s\t%s\n' \ + add "Add new protocol address" \ delete "Delete protocol address" \ show "Look at protocol addresses" \ - flush "Flush protocol addresses" + flush "Flush protocol addresses" \ + help "Display help" else switch $cmd[2] # Change and replace are undocumented (apart from mentions in the BNF) @@ -339,7 +341,8 @@ function __fish_complete_ip end case link if not set -q cmd[3] - printf '%s\t%s\n' add "Add virtual link" \ + printf '%s\t%s\n' \ + add "Add virtual link" \ delete "Delete virtual link" \ set "Change device attributes" \ show "Display device attributes" \ @@ -430,18 +433,20 @@ function __fish_complete_ip end case show case help + __fish_ip_types end end case neighbour if not set -q cmd[3] - printf '%s\t%s\n' help "Show help" \ + printf '%s\t%s\n' \ add "Add new neighbour entry" \ delete "Delete neighbour entry" \ change "Change neighbour entry" \ replace "Add or change neighbour entry" \ show "List neighbour entries" \ flush "Flush neighbour entries" \ - get "Lookup neighbour entry" + get "Lookup neighbour entry" \ + help "Display help" else switch $cmd[2] case add del delete change replace @@ -505,7 +510,8 @@ function __fish_complete_ip get "Get a single route" \ save "Save routing table to stdout" \ showdump "Show saved routing table from stdin" \ - restore "Restore routing table from stdin" + restore "Restore routing table from stdin" \ + help "Display help" else # TODO: switch on $cmd[2] and complete subcommand specific arguments # for now just complete most useful arguments for the last token @@ -524,7 +530,8 @@ function __fish_complete_ip flush "Flush rules" \ show "List rules" \ save "Save rules to stdout" \ - restore "Restore rules from stdin" + restore "Restore rules from stdin" \ + help "Display help" else # TODO: switch on $cmd[2] and complete subcommand specific arguments # for now just complete most useful arguments for the last token @@ -579,6 +586,27 @@ function __fish_complete_ip end end end + case tuntap + if not set -q cmd[3] + printf '%s\t%s\n' \ + add "Add a new tun or tap device" \ + del "Delete a tun or tap device" \ + show "Show tun and tap devices" \ + help "Display help" + else + switch $cmd[-2] + case dev + __fish_ip_device + case mode + printf '%s\n' tun tap + case user + __fish_complete_users + case group + __fish_complete_groups + case '*' + printf '%s\n' dev mode user group one_queue pi vnet_hdr multi_queue name + end + end end end