diff options
Diffstat (limited to 'completions/mdadm')
-rw-r--r-- | completions/mdadm | 116 |
1 files changed, 58 insertions, 58 deletions
diff --git a/completions/mdadm b/completions/mdadm index 37effd9..e67558d 100644 --- a/completions/mdadm +++ b/completions/mdadm @@ -1,16 +1,18 @@ # bash completion for mdadm -*- shell-script -*- -_mdadm_raid_level() +_comp_cmd_mdadm__raid_level() { - local mode + local mode="" + local i noargopts='!(-*|*[CB]*)' for ((i = 1; i < cword; i++)); do + # shellcheck disable=SC2254 case ${words[i]} in - -!(-*)C* | --create) + -${noargopts}C* | --create) mode=create break ;; - -!(-*)B* | --build) + -${noargopts}B* | --build) mode=build break ;; @@ -19,20 +21,19 @@ _mdadm_raid_level() case $mode in create) - COMPREPLY=($(compgen -W 'linear raid0 0 stripe raid1 1 mirror - raid4 4 raid5 5 raid6 6 raid10 10 multipath mp faulty' \ - -- "$cur")) + _comp_compgen -- -W 'linear raid0 0 stripe raid1 1 mirror raid4 4 + raid5 5 raid6 6 raid10 10 multipath mp faulty' ;; build) - COMPREPLY=($(compgen -W 'linear stripe raid0 0 raid1 multipath mp - faulty' -- "$cur")) + _comp_compgen -- -W 'linear stripe raid0 0 raid1 multipath mp + faulty' ;; esac } -_mdadm_raid_layout() +_comp_cmd_mdadm__raid_layout() { - local level + local i level="" for ((i = 1; i < cword; i++)); do if [[ ${words[i]} == -@(l|-level) ]]; then level=${words[i + 1]} @@ -42,108 +43,107 @@ _mdadm_raid_layout() case $level in raid5) - COMPREPLY=($(compgen -W 'left-asymmetric left-symmetric - right-asymmetric right-symmetric la ra ls rs' -- "$cur")) + _comp_compgen -- -W 'left-asymmetric left-symmetric + right-asymmetric right-symmetric la ra ls rs' ;; raid10) - COMPREPLY=($(compgen -W 'n o p' -- "$cur")) + _comp_compgen -- -W 'n o p' ;; faulty) - COMPREPLY=($(compgen -W 'write-transient wt read-transient rt + _comp_compgen -- -W 'write-transient wt read-transient rt write-persistent wp read-persistent rp write-all read-fixable - rf clear flush none' -- "$cur")) + rf clear flush none' ;; esac } -_mdadm_auto_flag() +_comp_cmd_mdadm__auto_flag() { - COMPREPLY=($(compgen -W 'no yes md mdp part p' -- "$cur")) + _comp_compgen -- -W 'no yes md mdp part p' } -_mdadm_update_flag() +_comp_cmd_mdadm__update_flag() { - COMPREPLY=($(compgen -W 'sparc2.2 summaries uuid name homehost resync - byteorder super-minor' -- "$cur")) + _comp_compgen -- -W 'sparc2.2 summaries uuid name homehost resync byteorder + super-minor' } -_mdadm() +_comp_cmd_mdadm() { - local cur prev words cword split - _init_completion -s || return + local cur prev words cword was_split comp_args + _comp_initialize -s -- "$@" || return + local noargopts='!(-*|*[cblpaU]*)' + # shellcheck disable=SC2254 case $prev in - --config | --bitmap | --backup-file | -!(-*)[cb]) - _filedir + --config | --bitmap | --backup-file | -${noargopts}[cb]) + _comp_compgen_filedir return ;; - --level | -!(-*)l) - _mdadm_raid_level + --level | -${noargopts}l) + _comp_cmd_mdadm__raid_level return ;; - --layout | --parity | -!(-*)p) - _mdadm_raid_layout + --layout | --parity | -${noargopts}p) + _comp_cmd_mdadm__raid_layout return ;; - --auto | -!(-*)a) - _mdadm_auto_flag + --auto | -${noargopts}a) + _comp_cmd_mdadm__auto_flag return ;; - --update | -!(-*)U) - _mdadm_update_flag + --update | -${noargopts}U) + _comp_cmd_mdadm__update_flag return ;; esac - $split && return + [[ $was_split ]] && return local options='--help --help-options --version --verbose --quiet --brief --force --config= --scan --metadata= --homehost=' if [[ $cur == -* ]]; then if ((cword == 1)); then - COMPREPLY=($(compgen -W "$options --assemble --build --create - --monitor --grow" -- "$cur")) + _comp_compgen -- -W "$options --assemble --build --create --monitor + --grow" else + # shellcheck disable=SC2254 case ${words[cword - 1]} in - --assemble | -!(-*)A*) - COMPREPLY=($(compgen -W "$options --uuid= --super-minor= + --assemble | -${noargopts}A*) + _comp_compgen -- -W "$options --uuid= --super-minor= --name= --force --run --no-degraded --auto= --bitmap= - --backup-file= --update= --auto-update-homehost" \ - -- "$cur")) + --backup-file= --update= --auto-update-homehost" ;; - --build | --create | --grow | -!(-*)[BCG]*) - COMPREPLY=($(compgen -W "$options --raid-devices= + --build | --create | --grow | -${noargopts}[BCG]*) + _comp_compgen -- -W "$options --raid-devices= --spare-devices= --size= --chunk= --rounding= --level= --layout= --parity= --bitmap= --bitmap-chunk= --write-mostly --write-behind= --assume-clean - --backup-file= --name= --run --force --auto=" \ - -- "$cur")) + --backup-file= --name= --run --force --auto=" ;; - --follow | --monitor | -!(-*)F) - COMPREPLY=($(compgen -W "$options --mail --program - --alert --syslog --delay --daemonise --pid-file - --oneshot --test" -- "$cur")) + --follow | --monitor | -${noargopts}F) + _comp_compgen -- -W "$options --mail --program --alert + --syslog --delay --daemonise --pid-file --oneshot + --test" ;; /dev/* | --add | --fail | --remove) - COMPREPLY=($(compgen -W "$options --add --re-add - --remove --fail --set-faulty" -- "$cur")) + _comp_compgen -- -W "$options --add --re-add --remove + --fail --set-faulty" ;; *) - COMPREPLY=($(compgen -W "$options --query --detail - --examine --sparc2.2 --examine-bitmap --run --stop - --readonly --readwrite --zero-superblock --test" \ - -- "$cur")) + _comp_compgen -- -W "$options --query --detail --examine + --sparc2.2 --examine-bitmap --run --stop --readonly + --readwrite --zero-superblock --test" ;; esac fi [[ ${COMPREPLY-} == *= ]] && compopt -o nospace else - cur=${cur:=/dev/} - _filedir + _comp_compgen -c "${cur:-/dev/}" filedir fi } && - complete -F _mdadm mdadm + complete -F _comp_cmd_mdadm mdadm # ex: filetype=sh |