diff --git a/command-signatures/json/ip.json b/command-signatures/json/ip.json new file mode 100644 index 00000000..11697561 --- /dev/null +++ b/command-signatures/json/ip.json @@ -0,0 +1,311 @@ +{ + "name": "ip", + "description": "Show and manipulate routing, network devices, interfaces and tunnels", + "subcommands": [ + { + "name": "address", + "description": "Protocol (IP or IPv6) address on a device" + }, + { + "name": "addrlabel", + "description": "Label configuration for protocol address selection" + }, + { + "name": "fou", + "description": "Foo-over-UDP receive port configuration" + }, + { + "name": "help", + "description": "Display a list of supported commands and arguments" + }, + { + "name": "ila", + "description": "Manage identifier locator addressing (ILA)" + }, + { + "name": "ioam", + "description": "Manage in-situ OAM (IOAM)" + }, + { + "name": "l2tp", + "description": "Tunnel ethernet over IP (L2TPv3)" + }, + { + "name": "link", + "description": "Network device configuration" + }, + { + "name": "macsec", + "description": "MACsec device configuration" + }, + { + "name": "maddress", + "description": "Multicast address" + }, + { + "name": "monitor", + "description": "Watch for netlink messages" + }, + { + "name": "mptcp", + "description": "Manage MPTCP path manager" + }, + { + "name": "mroute", + "description": "Multicast routing cache entry" + }, + { + "name": "mrule", + "description": "Rule in multicast routing policy database" + }, + { + "name": "neighbour", + "description": "ARP or NDISC cache entry" + }, + { + "name": "netconf", + "description": "Network configuration monitoring" + }, + { + "name": "netns", + "description": "Manage network namespaces" + }, + { + "name": "nexthop", + "description": "Manage nexthop objects" + }, + { + "name": "ntable", + "description": "Manage the neighbor cache's operation" + }, + { + "name": "route", + "description": "Routing table entry" + }, + { + "name": "rule", + "description": "Rule in routing policy database" + }, + { + "name": "sr", + "description": "Manage IPv6 Segment Routing" + }, + { + "name": "tap", + "description": "Manage TUN/TAP devices" + }, + { + "name": "tcpmetrics", + "description": "Manage TCP metrics" + }, + { + "name": "token", + "description": "Manage tokenized interface identifiers" + }, + { + "name": "tunnel", + "description": "Tunnel over IP" + }, + { + "name": "tuntap", + "description": "Manage TUN/TAP devices" + }, + { + "name": "vrf", + "description": "Manage virtual routing and forwarding devices" + }, + { + "name": "xfrm", + "description": "Manage IPSec policies" + } + ], + "options": [ + { + "name": [ + "-V", + "-Version" + ], + "description": "Display the version of the ip utility" + }, + { + "name": [ + "-s", + "-statistics", + "-stats" + ], + "description": "Output more information (may be used twice for even more)" + }, + { + "name": [ + "-d", + "-details" + ], + "description": "Output more detailed information" + }, + { + "name": [ + "-r", + "-resolve" + ], + "description": "Print DNS names instead of host addresses" + }, + { + "name": [ + "-h", + "-human-readable", + "-human" + ], + "description": "Output statistics with human-readable values" + }, + { + "name": "-iec", + "description": "Print human-readable rates in IEC units (e.g. 1Ki = 1024)" + }, + { + "name": [ + "-j", + "-json" + ], + "description": "Output results in JSON format" + }, + { + "name": [ + "-p", + "-pretty" + ], + "description": "Pretty-print JSON output (implies -json)" + }, + { + "name": [ + "-f", + "-family" + ], + "description": "Protocol family to use", + "args": { + "name": "FAMILY", + "suggestions": [ + "inet", + "inet6", + "mpls", + "bridge", + "link" + ] + } + }, + { + "name": "-4", + "description": "Shortcut for -family inet" + }, + { + "name": "-6", + "description": "Shortcut for -family inet6" + }, + { + "name": "-M", + "description": "Shortcut for -family mpls" + }, + { + "name": "-B", + "description": "Shortcut for -family bridge" + }, + { + "name": "-0", + "description": "Shortcut for -family link" + }, + { + "name": [ + "-l", + "-loops" + ], + "description": "Maximum number of loops for 'ip address flush'", + "args": { + "name": "COUNT" + } + }, + { + "name": [ + "-br", + "-brief" + ], + "description": "Print only basic information in a tabular format" + }, + { + "name": [ + "-o", + "-oneline" + ], + "description": "Output each record on a single line, replacing line feeds with backslashes" + }, + { + "name": [ + "-t", + "-timestamp" + ], + "description": "Display current time when using monitor" + }, + { + "name": [ + "-ts", + "-tshort" + ], + "description": "Like -timestamp, but use shorter format" + }, + { + "name": [ + "-b", + "-batch" + ], + "description": "Read commands from provided file or standard input", + "args": { + "name": "FILENAME", + "template": "filepaths" + } + }, + { + "name": [ + "-rc", + "-rcvbuf" + ], + "description": "Set the netlink socket receive buffer size (default: 1MB)", + "args": { + "name": "SIZE" + } + }, + { + "name": [ + "-n", + "-netns" + ], + "description": "Switch to the specified network namespace", + "args": { + "name": "NETNS", + "generatorName": "netns" + } + }, + { + "name": [ + "-N", + "-Numeric" + ], + "description": "Print protocol, scope, dsfield, etc. as numbers instead of names" + }, + { + "name": [ + "-a", + "-all" + ], + "description": "Execute specified command over all objects" + }, + { + "name": [ + "-c", + "-color" + ], + "description": "Use color output" + }, + { + "name": "-force", + "description": "Don't terminate on errors in batch mode" + } + ] +} diff --git a/command-signatures/src/generators/ip.rs b/command-signatures/src/generators/ip.rs new file mode 100644 index 00000000..d1b04c1e --- /dev/null +++ b/command-signatures/src/generators/ip.rs @@ -0,0 +1,25 @@ +use warp_completion_metadata::{ + CommandBuilder, CommandSignatureGenerators, Generator, GeneratorResultsCollector, Suggestion, +}; + +pub fn generator() -> CommandSignatureGenerators { + CommandSignatureGenerators::new("ip").add_generator( + "netns", + Generator::script( + CommandBuilder::single_command("ip netns list 2>/dev/null"), + |output| { + output + .lines() + .filter_map(|line| { + // Output format: "name" or "name (id: N)" + let name = line.split_whitespace().next()?; + if name.is_empty() { + return None; + } + Some(Suggestion::with_description(name, "Network namespace")) + }) + .collect_unordered_results() + }, + ), + ) +} diff --git a/command-signatures/src/generators/mod.rs b/command-signatures/src/generators/mod.rs index e97e1426..29f1488f 100644 --- a/command-signatures/src/generators/mod.rs +++ b/command-signatures/src/generators/mod.rs @@ -30,6 +30,7 @@ mod git; mod go; mod gt; mod heroku; +mod ip; mod kill; mod killall; mod kubecolor; @@ -91,6 +92,7 @@ pub fn dynamic_command_signature_data() -> HashMap