@@ -23,27 +23,36 @@ _netctl_complete_tenants() {
23
23
_netctl_complete_networks () {
24
24
local tenant
25
25
tenant=$( _netctl_fetch_tenant_value)
26
- fields=' $2'
27
- COMPREPLY=( $( compgen -W ' $(netctl network ls --tenant $tenant -q")' -- " $cur " ) )
26
+ COMPREPLY=( $( compgen -W ' $(netctl network ls --tenant $tenant -q)' -- " $cur " ) )
28
27
}
29
28
30
29
# Fetch all policy names in the tenant
31
30
_netctl_complete_policies () {
32
31
local tenant
33
32
tenant=$( _netctl_fetch_tenant_value)
34
- fields=' $2'
35
33
COMPREPLY=( $( compgen -W ' $(netctl policy ls --tenant $tenant -q)' -- " $cur " ) )
36
34
}
37
35
38
36
# Fetch all group names in the tenant
39
37
_netctl_complete_groups () {
40
38
local tenant
41
39
tenant=$( _netctl_fetch_tenant_value)
42
- fields=' $2'
43
- COMPREPLY=( $( compgen -W ' $(netctl group ls --tenant $tenant -q")' -- " $cur " ) )
40
+ COMPREPLY=( $( compgen -W ' $(netctl group ls --tenant $tenant -q)' -- " $cur " ) )
41
+ }
42
+
43
+ _netctl_complete_rules () {
44
+ local tenant
45
+ tenant=$( _netctl_fetch_tenant_value)
46
+ policy=$( _netctl_fetch_policy_value)
47
+ if [ -z $policy ]; then
48
+ _netctl_fetch_options
49
+ return
50
+ fi
51
+ COMPREPLY=( $( compgen -W ' $(netctl rule ls --policy $policy --tenant $tenant -q)' -- " $cur " ) )
44
52
}
45
53
46
54
55
+
47
56
_netctl () {
48
57
local cur prev firstword secondword complete_words complete_options
49
58
@@ -199,7 +208,7 @@ _netctl_network_rm() {
199
208
case " $prev " in
200
209
--tenant|-t)
201
210
_netctl_complete_tenants
202
- return
211
+ return
203
212
;;
204
213
esac
205
214
@@ -217,7 +226,7 @@ _netctl_network_ls() {
217
226
case " $prev " in
218
227
--tenant|-t)
219
228
_netctl_complete_tenants
220
- return
229
+ return
221
230
;;
222
231
esac
223
232
@@ -265,7 +274,7 @@ _netctl_policy_rm() {
265
274
case " $prev " in
266
275
--tenant|-t)
267
276
_netctl_complete_tenants
268
- return
277
+ return
269
278
;;
270
279
esac
271
280
@@ -283,7 +292,7 @@ _netctl_policy_ls() {
283
292
case " $prev " in
284
293
--tenant|-t)
285
294
_netctl_complete_tenants
286
- return
295
+ return
287
296
;;
288
297
esac
289
298
@@ -318,7 +327,7 @@ _netctl_group_rm() {
318
327
case " $prev " in
319
328
--tenant|-t)
320
329
_netctl_complete_tenants
321
- return
330
+ return
322
331
;;
323
332
esac
324
333
@@ -336,7 +345,7 @@ _netctl_group_ls() {
336
345
case " $prev " in
337
346
--tenant|-t)
338
347
_netctl_complete_tenants
339
- return
348
+ return
340
349
;;
341
350
esac
342
351
@@ -369,6 +378,10 @@ _netctl_rule_create() {
369
378
COMPREPLY=( $( compgen -W " accept deny" -- " $cur " ) )
370
379
return
371
380
;;
381
+ --policy|-p)
382
+ _netctl_complete_policies
383
+ return
384
+ ;;
372
385
esac
373
386
374
387
case " $cur " in
@@ -383,22 +396,34 @@ _netctl_rule_rm() {
383
396
case " $prev " in
384
397
--tenant|-t)
385
398
_netctl_complete_tenants
386
- return
399
+ return
400
+ ;;
401
+ --policy|-p)
402
+ _netctl_complete_policies
403
+ return
387
404
;;
388
405
esac
389
406
390
407
case " $cur " in
391
408
-* )
392
409
_netctl_fetch_options
393
410
;;
411
+
412
+ * )
413
+ _netctl_complete_rules
414
+ ;;
394
415
esac
395
416
}
396
417
397
418
_netctl_rule_ls () {
398
419
case " $prev " in
399
420
--tenant|-t)
400
421
_netctl_complete_tenants
401
- return
422
+ return
423
+ ;;
424
+ --policy|-p)
425
+ _netctl_complete_policies
426
+ return
402
427
;;
403
428
esac
404
429
@@ -446,7 +471,22 @@ _netctl_fetch_tenant_value() {
446
471
echo $tenant
447
472
}
448
473
449
- # Parses the entire command for the option that is requested
474
+ _netctl_fetch_policy_value () {
475
+ local policy
476
+ policy=$( _netctl_option_val_get ' --policy' )
477
+ if [ -z $policy ]; then
478
+ policy=$( _netctl_option_val_get ' -p' )
479
+
480
+ if [ -z $policy ]
481
+ then
482
+ policy=" "
483
+ fi
484
+ fi
485
+ echo $policy
486
+ }
487
+
488
+
489
+ # Parses the entire command for the option that is requested
450
490
# and returns the next pattern as value
451
491
_netctl_option_val_get () {
452
492
local option_prop option_val i
0 commit comments