Skip to content

Commit e795bdf

Browse files
committed
etc: update bash completions
Problem: The bash completions are slightly out of date, there's some missing commands and options, etc. Update bash completions for Flux, including: - fix handling of options for flux(1) itself, add --root, --parent - add missing completions for flux-uri(1) - fix a mistake where shared flux-batch(1) and flux-alloc(1) options were dropped from completions - add --stream option to kvs command where appropriate - add completions for `flux overlay errors` - add `--sort` option for flux-jobs(1)
1 parent 1197465 commit e795bdf

File tree

1 file changed

+49
-7
lines changed

1 file changed

+49
-7
lines changed

etc/completions/flux.pre

Lines changed: 49 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -468,10 +468,12 @@ _flux_submit_commands()
468468
"
469469
local batch_OPTS="\
470470
$COMMON_OPTIONS \
471+
$BATCH_ALLOC_OPTIONS \
471472
$BATCH_OPTIONS \
472473
"
473474
local alloc_OPTS="\
474475
$COMMON_OPTIONS \
476+
$BATCH_ALLOC_OPTIONS \
475477
$ALLOC_OPTIONS \
476478
"
477479
_flux_split_longopt && split=true
@@ -949,6 +951,7 @@ _flux_kvs_eventlog()
949951
-u --unformatted \
950952
-H --human \
951953
-L --color= \
954+
-S --stream \
952955
"
953956
local wait_event_OPTS="\
954957
-N --namespace= \
@@ -1022,6 +1025,7 @@ _flux_kvs()
10221025
-A --append \
10231026
-f --full \
10241027
-c --count= \
1028+
-S --stream \
10251029
"
10261030
put_OPTS="\
10271031
-N --namespace= \
@@ -1137,7 +1141,7 @@ _flux_kvs()
11371141
_flux_overlay()
11381142
{
11391143
local cmd=$1
1140-
local subcmds="status lookup parentof disconnect trace"
1144+
local subcmds="status lookup parentof disconnect trace errors"
11411145
local split=false
11421146

11431147
local status_OPTS="\
@@ -1172,6 +1176,10 @@ _flux_overlay()
11721176
-d --delta \
11731177
-f --full \
11741178
"
1179+
local errors_OPTS="\
1180+
-h --help \
1181+
-t --timeout= \
1182+
"
11751183
_flux_split_longopt && split=true
11761184
case $prev in
11771185
-!(-*)[rtwH])
@@ -1415,6 +1423,7 @@ _flux_jobs()
14151423
--threads= \
14161424
--stats \
14171425
--stats-only \
1426+
--sort= \
14181427
"
14191428

14201429
_flux_split_longopt && split=true
@@ -1427,7 +1436,7 @@ _flux_jobs()
14271436
_flux_complete_format_name flux jobs
14281437
return
14291438
;;
1430-
-!(-*)[Lcf])
1439+
--sort | -!(-*)[Lcf])
14311440
return
14321441
;;
14331442
esac
@@ -1983,10 +1992,17 @@ _flux_start()
19831992
-o --broker-opts= \
19841993
--wrap= \
19851994
-s --test-size= \
1995+
-c --config-path = \
1996+
-S --setattr= \
19861997
"
19871998
_flux_split_longopt && split=true
19881999
case $prev in
1989-
-!(-*)[os])
2000+
-!(-*)[osS])
2001+
return
2002+
;;
2003+
--config-path | -!(-*)c)
2004+
compopt -o filenames
2005+
COMPREPLY=( $(compgen -f -- "$cur") $(compgen -d -- "$cur") )
19902006
return
19912007
;;
19922008
esac
@@ -2084,8 +2100,34 @@ _flux_housekeeping()
20842100
fi
20852101
}
20862102

2103+
# flux-uri(1) completions
2104+
_flux_uri()
2105+
{
2106+
local cmd=$1
2107+
local split=false
2108+
local OPTS="\
2109+
--remote \
2110+
--local \
2111+
--wait
2112+
"
2113+
if [[ $cur != -* ]]; then
2114+
# Attempt to substitute an active jobid
2115+
active_jobs=$(flux jobs -no $(_flux_id_fmt $cur))
2116+
COMPREPLY=( $(compgen -W "${active_jobs}" -- "$cur") )
2117+
return 0
2118+
fi
2119+
2120+
COMPREPLY=( $(compgen -W "${OPTS} -h --help" -- "$cur") )
2121+
if [[ "${COMPREPLY[@]}" == *= ]]; then
2122+
# Add space if there is not a '=' in suggestions
2123+
compopt -o nospace
2124+
fi
2125+
return 0
2126+
}
2127+
20872128
_flux_core()
20882129
{
2130+
FLUX_OPTS="-v --verbose -V --version -p --parent -r --root"
20892131
local cur prev cmd subcmd matched
20902132
local cmds=$(__get_flux_subcommands)
20912133
cmd=$(_flux_get_cmd)
@@ -2209,18 +2251,18 @@ _flux_core()
22092251
housekeeping)
22102252
_flux_housekeeping $subcmd
22112253
;;
2212-
-*)
2213-
COMPREPLY=( $(compgen -W "${FLUX_OPTS}" -- "$cur") )
2254+
uri)
2255+
_flux_uri $subcmd
22142256
;;
22152257
help)
22162258
COMPREPLY=( $(compgen -W "${cmds}" -- "$cur") )
22172259
;;
22182260
*)
22192261
# return with no suggestions for unknown subcommands:
2220-
[[ "$prev" != "flux" ]] && return
2262+
[[ "$prev" != "flux" && "$prev" != -* ]] && return
22212263

22222264
matched=f
2223-
COMPREPLY=( $(compgen -W "${cmds}" -- "$cur") )
2265+
COMPREPLY=( $(compgen -W "${FLUX_OPTS} ${cmds}" -- "$cur") )
22242266
;;
22252267
esac
22262268

0 commit comments

Comments
 (0)