Skip to content

Commit 05e9904

Browse files
committed
iw: New completion
1 parent 8bea1ec commit 05e9904

File tree

1 file changed

+293
-0
lines changed
  • completions

1 file changed

+293
-0
lines changed

completions/iw

Lines changed: 293 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,293 @@
1+
# iw(8) completion -*- shell-script -*-
2+
3+
_iw()
4+
{
5+
local cur prev words cword
6+
_init_completion || return
7+
8+
local subcword obj cmd
9+
for (( subcword=1; subcword < cword; subcword++ )); do
10+
[[ "${words[subcword]}" == --version ]] && return
11+
if [[ -n $obj ]]; then
12+
case $obj in
13+
phy|dev|wdev)
14+
if [[ $subcword+1 -lt $cword ]]; then
15+
cmd=${words[subcword+1]}
16+
(( subcword++ ))
17+
break
18+
fi
19+
;;
20+
esac && break
21+
fi
22+
[[ "${words[subcword]}" != -* ]] && obj=${words[subcword]}
23+
done
24+
25+
if [[ -z $obj ]]; then
26+
case $cur in
27+
-*)
28+
local c="--version --debug"
29+
COMPREPLY=( $( compgen -W "$c" -- "$cur" ) )
30+
return
31+
;;
32+
*)
33+
COMPREPLY=( $( compgen -W "commands dev event features help list phy reg wdev" -- "$cur" ) )
34+
return
35+
;;
36+
esac
37+
fi
38+
39+
if [[ $obj == help ]]; then
40+
COMPREPLY=( $( compgen -W "ap cac channels coalesce connect cqm del\
41+
dev disconnect get ibss info interface link mesh mpath mpp ocb \
42+
offchannel phy p2p reg roc scan set station survey switch vendor \
43+
wowlan" -- "$cur") )
44+
return
45+
fi
46+
47+
case $obj in
48+
dev)
49+
if [[ $prev == dev ]]; then
50+
_available_interfaces
51+
return
52+
elif [[ -z $cmd ]]; then
53+
COMPREPLY=( $( compgen -W "ap cac connect cqm del \
54+
disconnect get ibss info interface link mesh mpath mpp\
55+
ocb offchannel roc scan set station survey switch \
56+
vendor" -- "$cur") )
57+
return
58+
elif [[ $prev == $cmd ]]; then
59+
case $cmd in
60+
ap)
61+
COMPREPLY=( $( compgen -W "start stop" -- "$cur" ) )
62+
return
63+
;;
64+
cac)
65+
COMPREPLY=( $( compgen -W "channel freq trigger" -- "$cur" ) )
66+
return
67+
;;
68+
cqm)
69+
COMPREPLY=( $( compgen -W "rssi" -- "$cur" ) )
70+
return
71+
;;
72+
del)
73+
return
74+
;;
75+
disconnect)
76+
return
77+
;;
78+
get)
79+
COMPREPLY=( $( compgen -W "mesh_param power_save" -- "$cur" ) )
80+
return
81+
;;
82+
ibss)
83+
COMPREPLY=( $( compgen -W "join leave" -- "$cur" ) )
84+
return
85+
;;
86+
info)
87+
return
88+
;;
89+
interface)
90+
COMPREPLY=( $( compgen -W "add" -- "$cur" ) )
91+
return
92+
;;
93+
link)
94+
return
95+
;;
96+
mesh)
97+
COMPREPLY=( $( compgen -W "join leave" -- "$cur" ) )
98+
return
99+
;;
100+
mpath)
101+
COMPREPLY=( $( compgen -W "del dump get new set" -- "$cur" ) )
102+
return
103+
;;
104+
mpp)
105+
COMPREPLY=( $( compgen -W "dump get" -- "$cur" ) )
106+
return
107+
;;
108+
ocb)
109+
COMPREPLY=( $( compgen -W "join leave" -- "$cur" ) )
110+
return
111+
;;
112+
offchannel)
113+
return
114+
;;
115+
roc)
116+
COMPREPLY=( $( compgen -W "start" -- "$cur" ) )
117+
return
118+
;;
119+
scan)
120+
COMPREPLY=( $( compgen -W "abort dump sched_stop" -- "$cur" ) )
121+
return
122+
;;
123+
set)
124+
COMPREPLY=( $( compgen -W "4addr channel freq mcast_rate meshid mesh_param monitor noack_map peer power_save txpower type" -- "$cur" ) )
125+
return
126+
;;
127+
station)
128+
COMPREPLY=( $( compgen -W "del dump get set" -- "$cur" ) )
129+
return
130+
;;
131+
survey)
132+
COMPREPLY=( $( compgen -W "dump" -- "$cur" ) )
133+
return
134+
;;
135+
switch)
136+
COMPREPLY=( $( compgen -W "channel freq" -- "$cur" ) )
137+
return
138+
;;
139+
vendor)
140+
COMPREPLY=( $( compgen -W "recv recvbin send" -- "$cur" ) )
141+
return
142+
;;
143+
esac
144+
else
145+
case $cmd in
146+
cac)
147+
case $prev in
148+
channel)
149+
;;
150+
freq)
151+
if [[ $prev == freq ]]; then
152+
COMPREPLY=( $( compgen -W "chanel freq" -- "$cur" ) )
153+
return
154+
fi
155+
;;
156+
trigger)
157+
return
158+
;;
159+
esac
160+
;;
161+
get)
162+
if [[ "${words[subcword+1]}" == "mesh_param" ]]; then
163+
COMPREPLY=( $( compgen -W "$( "${words[@]:0:cword}" sed -n '/\s\+-\s\+/{s/\s\+-\s\+//;p}' )" -- "$cur" ) )
164+
fi
165+
;;
166+
interface)
167+
case "$(( cword-subcword ))" in
168+
2)
169+
COMPREPLY=( $( compgen -W "type" -- "$cur" ) )
170+
return
171+
;;
172+
3)
173+
COMPREPLY=( $( compgen -W "none fcsfail control otherbss cook active mumimo-groupid mumimo-follow-mac" -- "$cur" ) )
174+
return
175+
;;
176+
4)
177+
COMPREPLY=( $( compgen -W "mesh_id 4addr flags addr" -- "$cur" ) )
178+
return
179+
;;
180+
esac
181+
;;
182+
set)
183+
local c
184+
case "${words[subcword+1]}" in
185+
4addr)
186+
c="on off"
187+
;;
188+
channel)
189+
if [[ $prev != "channel" ]]; then
190+
c="NOHT HT20 HT40+ HT40- 5MHz 10MHz 80MHz"
191+
fi
192+
;;
193+
freq)
194+
#TODO
195+
;;
196+
mesh_param)
197+
if [[ $prev == mesh_param ]]; then
198+
COMPREPLY=( $( compgen -W "$( "${words[@]:0:cword}" | sed -n '/\s\+-\s\+/{s/\s\+-\s\+//;p}' )" -- "$cur" ) )
199+
fi
200+
return
201+
;;
202+
monitor)
203+
COMPREPLY=( $( compgen -W "none fcsfail control otherbss cook active mumimo-groupid mumimo-follow-mac" -- "$cur" ) )
204+
return
205+
;;
206+
power_save)
207+
COMPREPLY=( $( compgen -W "on off" -- "$cur" ) )
208+
return
209+
;;
210+
txpower)
211+
COMPREPLY=( $( compgen -W "auto fixed limit" -- "$cur" ) )
212+
return
213+
;;
214+
type)
215+
COMPREPLY=( $( compgen -W "managed ibss monitor mesh wds" -- "$cur" ) )
216+
return
217+
;;
218+
esac
219+
;;
220+
station)
221+
case "${words[subcword+1]}" in
222+
set)
223+
case "$(( cword-subcword ))" in
224+
2)
225+
COMPREPLY=( $( compgen -W "mesh_power_mode vlan plink_action" -- "$cur" ) )
226+
return
227+
;;
228+
3)
229+
case $prev in
230+
mesh_power_mode)
231+
COMPREPLY=( $( compgen -W "active light deep" -- "$cur" ) )
232+
return
233+
;;
234+
plink_action)
235+
COMPREPLY=( $( compgen -W "open block" -- "$cur" ) )
236+
return
237+
;;
238+
esac
239+
;;
240+
esac
241+
;;
242+
del)
243+
if [[ cword-subcword -eq 2 ]]; then
244+
COMPREPLY=( $( compgen -W "subtype reason-code" -- "$cur" ) )
245+
fi
246+
esac
247+
;;
248+
esac
249+
fi
250+
;;
251+
phy)
252+
if [[ $prev == phy ]]; then
253+
COMPREPLY=( $( compgen -W $( ls /sys/class/ieee80211/ ) -- "$cur" ) )
254+
return
255+
elif [[ -z $cmd ]]; then
256+
COMPREPLY=( $( compgen -W "channels coalesce info interface reg set wowlan" -- "$cur" ) )
257+
return
258+
elif [[ $prev == $cmd ]]; then
259+
case $cmd in
260+
channels)
261+
return
262+
;;
263+
coalesce)
264+
COMPREPLY=( $( compgen -W "disable enable show" -- "$cur" ) )
265+
return
266+
;;
267+
info)
268+
return
269+
;;
270+
interface)
271+
COMPREPLY=( $( compgen -W "add" -- "$cur" ) )
272+
return
273+
;;
274+
reg)
275+
COMPREPLY=( $( compgen -W "get" -- "$cur" ) )
276+
return
277+
;;
278+
set)
279+
COMPREPLY=( $( compgen -W "antenna channel coverage distance frag freq name netns retry rts txpower" -- "$cur" ) )
280+
return
281+
;;
282+
wowlan)
283+
COMPREPLY=( $( compgen -W "disable enable show" -- "$cur" ) )
284+
return
285+
;;
286+
esac
287+
fi
288+
;;
289+
esac
290+
291+
} && complete -F _iw iw
292+
293+
# ex: filetype=sh

0 commit comments

Comments
 (0)