From ebfa2cc3b690b4a31fcc6ccb22c95f778e14e22a Mon Sep 17 00:00:00 2001 From: "Mark A. Grondona" Date: Thu, 24 Aug 2023 07:12:50 -0700 Subject: [PATCH] completions: add bash completions for flux-update(1) Problem: There are no tab completions for the flux-update(1) command. Add a completion handler for flux-update(1) to etc/completions/flux.pre. --- etc/completions/flux.pre | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/etc/completions/flux.pre b/etc/completions/flux.pre index 26adc2ee0025..fcf8f016c63f 100644 --- a/etc/completions/flux.pre +++ b/etc/completions/flux.pre @@ -159,6 +159,29 @@ _flux_cancel() return 0 } +# flux-update(1) completions +_flux_update() +{ + local cmd=$1 + OPTS="\ + -v, --verbose \ + -n, --dry-run \ + " + if [[ $cur != -* ]]; then + # Attempt to substibute a pending jobid + compopt +o filenames + pending_jobs=$(flux jobs -f pending -no {id}) + COMPREPLY=( $(compgen -W "${pending_jobs}" -- "$cur") ) + return 0 + fi + COMPREPLY=( $(compgen -W "${OPTS} -h --help" -- "$cur") ) + if [[ "${COMPREPLY[@]}" == *= ]]; then + # Add space if there is not a '=' in suggestions + compopt -o nospace + fi + return 0 +} + # flux-mini(1) completions _flux_mini() { @@ -1474,6 +1497,9 @@ _flux_core() watch) _flux_watch $subcmd ;; + update) + _flux_update $subcmd + ;; -*) COMPREPLY=( $(compgen -W "${FLUX_OPTS}" -- "$cur") ) ;;