Skip to content

Commit 8d62313

Browse files
committed
completions: add bash completions for flux-hostlist(1)
Problem: There are no bash completions for flux-hostlist(1). Add them.
1 parent b53b45c commit 8d62313

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

etc/completions/flux.pre

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,40 @@ _flux_update()
188188
return 0
189189
}
190190

191+
# flux-hostlist(1) completions
192+
_flux_hostlist()
193+
{
194+
local cmd=$1
195+
OPTS="\
196+
-e --expand \
197+
-d --delimiter= \
198+
-c --count \
199+
-n --nth \
200+
-L --limit= \
201+
-S --sort \
202+
-x --exclude= \
203+
-u --union --unique \
204+
-i --intersect \
205+
-m --minus \
206+
-X --xor \
207+
-f --fallback \
208+
-q --quiet \
209+
"
210+
if [[ $cur != -* ]]; then
211+
# Substitute source name or recent jobid
212+
jobs="$(flux jobs -ano $(_flux_id_fmt $cur))"
213+
sources="local instance avail stdin $jobs"
214+
COMPREPLY=( $(compgen -W "$sources $jobs" -- "$cur") )
215+
return 0
216+
fi
217+
COMPREPLY=( $(compgen -W "${OPTS} -h --help" -- "$cur") )
218+
if [[ "${COMPREPLY[@]}" == *= ]]; then
219+
# Add space if there is not a '=' in suggestions
220+
compopt -o nospace
221+
fi
222+
return 0
223+
}
224+
191225
# flux-{run,submit,batch,alloc,bulksubmit}(1) completions
192226
_flux_submit_commands()
193227
{
@@ -1510,6 +1544,9 @@ _flux_core()
15101544
update)
15111545
_flux_update $subcmd
15121546
;;
1547+
hostlist)
1548+
_flux_hostlist $subcmd
1549+
;;
15131550
-*)
15141551
COMPREPLY=( $(compgen -W "${FLUX_OPTS}" -- "$cur") )
15151552
;;

0 commit comments

Comments
 (0)