Skip to content

Commit 776422b

Browse files
Add completion spec: iproute2 (ip) (#261)
Co-authored-by: Oz Agent <oz-agent@warp.dev>
1 parent 22e095c commit 776422b

3 files changed

Lines changed: 338 additions & 0 deletions

File tree

command-signatures/json/ip.json

Lines changed: 311 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,311 @@
1+
{
2+
"name": "ip",
3+
"description": "Show and manipulate routing, network devices, interfaces and tunnels",
4+
"subcommands": [
5+
{
6+
"name": "address",
7+
"description": "Protocol (IP or IPv6) address on a device"
8+
},
9+
{
10+
"name": "addrlabel",
11+
"description": "Label configuration for protocol address selection"
12+
},
13+
{
14+
"name": "fou",
15+
"description": "Foo-over-UDP receive port configuration"
16+
},
17+
{
18+
"name": "help",
19+
"description": "Display a list of supported commands and arguments"
20+
},
21+
{
22+
"name": "ila",
23+
"description": "Manage identifier locator addressing (ILA)"
24+
},
25+
{
26+
"name": "ioam",
27+
"description": "Manage in-situ OAM (IOAM)"
28+
},
29+
{
30+
"name": "l2tp",
31+
"description": "Tunnel ethernet over IP (L2TPv3)"
32+
},
33+
{
34+
"name": "link",
35+
"description": "Network device configuration"
36+
},
37+
{
38+
"name": "macsec",
39+
"description": "MACsec device configuration"
40+
},
41+
{
42+
"name": "maddress",
43+
"description": "Multicast address"
44+
},
45+
{
46+
"name": "monitor",
47+
"description": "Watch for netlink messages"
48+
},
49+
{
50+
"name": "mptcp",
51+
"description": "Manage MPTCP path manager"
52+
},
53+
{
54+
"name": "mroute",
55+
"description": "Multicast routing cache entry"
56+
},
57+
{
58+
"name": "mrule",
59+
"description": "Rule in multicast routing policy database"
60+
},
61+
{
62+
"name": "neighbour",
63+
"description": "ARP or NDISC cache entry"
64+
},
65+
{
66+
"name": "netconf",
67+
"description": "Network configuration monitoring"
68+
},
69+
{
70+
"name": "netns",
71+
"description": "Manage network namespaces"
72+
},
73+
{
74+
"name": "nexthop",
75+
"description": "Manage nexthop objects"
76+
},
77+
{
78+
"name": "ntable",
79+
"description": "Manage the neighbor cache's operation"
80+
},
81+
{
82+
"name": "route",
83+
"description": "Routing table entry"
84+
},
85+
{
86+
"name": "rule",
87+
"description": "Rule in routing policy database"
88+
},
89+
{
90+
"name": "sr",
91+
"description": "Manage IPv6 Segment Routing"
92+
},
93+
{
94+
"name": "tap",
95+
"description": "Manage TUN/TAP devices"
96+
},
97+
{
98+
"name": "tcpmetrics",
99+
"description": "Manage TCP metrics"
100+
},
101+
{
102+
"name": "token",
103+
"description": "Manage tokenized interface identifiers"
104+
},
105+
{
106+
"name": "tunnel",
107+
"description": "Tunnel over IP"
108+
},
109+
{
110+
"name": "tuntap",
111+
"description": "Manage TUN/TAP devices"
112+
},
113+
{
114+
"name": "vrf",
115+
"description": "Manage virtual routing and forwarding devices"
116+
},
117+
{
118+
"name": "xfrm",
119+
"description": "Manage IPSec policies"
120+
}
121+
],
122+
"options": [
123+
{
124+
"name": [
125+
"-V",
126+
"-Version"
127+
],
128+
"description": "Display the version of the ip utility"
129+
},
130+
{
131+
"name": [
132+
"-s",
133+
"-statistics",
134+
"-stats"
135+
],
136+
"description": "Output more information (may be used twice for even more)"
137+
},
138+
{
139+
"name": [
140+
"-d",
141+
"-details"
142+
],
143+
"description": "Output more detailed information"
144+
},
145+
{
146+
"name": [
147+
"-r",
148+
"-resolve"
149+
],
150+
"description": "Print DNS names instead of host addresses"
151+
},
152+
{
153+
"name": [
154+
"-h",
155+
"-human-readable",
156+
"-human"
157+
],
158+
"description": "Output statistics with human-readable values"
159+
},
160+
{
161+
"name": "-iec",
162+
"description": "Print human-readable rates in IEC units (e.g. 1Ki = 1024)"
163+
},
164+
{
165+
"name": [
166+
"-j",
167+
"-json"
168+
],
169+
"description": "Output results in JSON format"
170+
},
171+
{
172+
"name": [
173+
"-p",
174+
"-pretty"
175+
],
176+
"description": "Pretty-print JSON output (implies -json)"
177+
},
178+
{
179+
"name": [
180+
"-f",
181+
"-family"
182+
],
183+
"description": "Protocol family to use",
184+
"args": {
185+
"name": "FAMILY",
186+
"suggestions": [
187+
"inet",
188+
"inet6",
189+
"mpls",
190+
"bridge",
191+
"link"
192+
]
193+
}
194+
},
195+
{
196+
"name": "-4",
197+
"description": "Shortcut for -family inet"
198+
},
199+
{
200+
"name": "-6",
201+
"description": "Shortcut for -family inet6"
202+
},
203+
{
204+
"name": "-M",
205+
"description": "Shortcut for -family mpls"
206+
},
207+
{
208+
"name": "-B",
209+
"description": "Shortcut for -family bridge"
210+
},
211+
{
212+
"name": "-0",
213+
"description": "Shortcut for -family link"
214+
},
215+
{
216+
"name": [
217+
"-l",
218+
"-loops"
219+
],
220+
"description": "Maximum number of loops for 'ip address flush'",
221+
"args": {
222+
"name": "COUNT"
223+
}
224+
},
225+
{
226+
"name": [
227+
"-br",
228+
"-brief"
229+
],
230+
"description": "Print only basic information in a tabular format"
231+
},
232+
{
233+
"name": [
234+
"-o",
235+
"-oneline"
236+
],
237+
"description": "Output each record on a single line, replacing line feeds with backslashes"
238+
},
239+
{
240+
"name": [
241+
"-t",
242+
"-timestamp"
243+
],
244+
"description": "Display current time when using monitor"
245+
},
246+
{
247+
"name": [
248+
"-ts",
249+
"-tshort"
250+
],
251+
"description": "Like -timestamp, but use shorter format"
252+
},
253+
{
254+
"name": [
255+
"-b",
256+
"-batch"
257+
],
258+
"description": "Read commands from provided file or standard input",
259+
"args": {
260+
"name": "FILENAME",
261+
"template": "filepaths"
262+
}
263+
},
264+
{
265+
"name": [
266+
"-rc",
267+
"-rcvbuf"
268+
],
269+
"description": "Set the netlink socket receive buffer size (default: 1MB)",
270+
"args": {
271+
"name": "SIZE"
272+
}
273+
},
274+
{
275+
"name": [
276+
"-n",
277+
"-netns"
278+
],
279+
"description": "Switch to the specified network namespace",
280+
"args": {
281+
"name": "NETNS",
282+
"generatorName": "netns"
283+
}
284+
},
285+
{
286+
"name": [
287+
"-N",
288+
"-Numeric"
289+
],
290+
"description": "Print protocol, scope, dsfield, etc. as numbers instead of names"
291+
},
292+
{
293+
"name": [
294+
"-a",
295+
"-all"
296+
],
297+
"description": "Execute specified command over all objects"
298+
},
299+
{
300+
"name": [
301+
"-c",
302+
"-color"
303+
],
304+
"description": "Use color output"
305+
},
306+
{
307+
"name": "-force",
308+
"description": "Don't terminate on errors in batch mode"
309+
}
310+
]
311+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
use warp_completion_metadata::{
2+
CommandBuilder, CommandSignatureGenerators, Generator, GeneratorResultsCollector, Suggestion,
3+
};
4+
5+
pub fn generator() -> CommandSignatureGenerators {
6+
CommandSignatureGenerators::new("ip").add_generator(
7+
"netns",
8+
Generator::script(
9+
CommandBuilder::single_command("ip netns list 2>/dev/null"),
10+
|output| {
11+
output
12+
.lines()
13+
.filter_map(|line| {
14+
// Output format: "name" or "name (id: N)"
15+
let name = line.split_whitespace().next()?;
16+
if name.is_empty() {
17+
return None;
18+
}
19+
Some(Suggestion::with_description(name, "Network namespace"))
20+
})
21+
.collect_unordered_results()
22+
},
23+
),
24+
)
25+
}

command-signatures/src/generators/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ mod git;
3030
mod go;
3131
mod gt;
3232
mod heroku;
33+
mod ip;
3334
mod kill;
3435
mod killall;
3536
mod kubecolor;
@@ -93,6 +94,7 @@ pub fn dynamic_command_signature_data() -> HashMap<String, DynamicCompletionData
9394
gt::generator(),
9495
go::generator(),
9596
heroku::generator(),
97+
ip::generator(),
9698
make::generator(),
9799
man::generator(),
98100
ng::generator(),

0 commit comments

Comments
 (0)