diff options
author | David Paleino <dapal@debian.org> | 2011-02-06 21:26:41 +0100 |
---|---|---|
committer | David Paleino <dapal@debian.org> | 2011-02-06 21:26:41 +0100 |
commit | 9920a8faedf704420571d8072ccab27e9dac40ba (patch) | |
tree | 733edf3b07be06c130d04aaa1884213326722cad /completions/mdadm | |
parent | f9748115fb4b2950fb4df7535fb723c4affde078 (diff) | |
download | bash-completion-9920a8faedf704420571d8072ccab27e9dac40ba.tar.gz |
Imported Upstream version 1.3upstream/1.3
Diffstat (limited to 'completions/mdadm')
-rw-r--r-- | completions/mdadm | 162 |
1 files changed, 162 insertions, 0 deletions
diff --git a/completions/mdadm b/completions/mdadm new file mode 100644 index 00000000..9cbaad7b --- /dev/null +++ b/completions/mdadm @@ -0,0 +1,162 @@ +# bash completion for mdadm + +have mdadm && +{ +_mdadm_raid_level() +{ + local mode + + for (( i=1; i < COMP_CWORD; i++ )); do + case ${COMP_WORDS[i]} in + -C|--create) + mode=create + break + ;; + -B|--build) + mode=build + break + ;; + esac + done + + 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" ) ) + ;; + build) + COMPREPLY=( $( compgen -W 'linear stripe raid0 0 raid1 multipath \ + mp faulty' -- "$cur" ) ) + ;; + esac +} + +_mdadm_raid_layout() +{ + local level + for (( i=1; i < COMP_CWORD; i++ )); do + if [[ "${COMP_WORDS[i]}" == -@(l|-level) ]]; then + level=${COMP_WORDS[i+1]} + break + fi + done + + case $level in + raid5) + COMPREPLY=( $( compgen -W 'left-asymmetric left-symmetric \ + right-asymmetric right-symmetric la ra ls rs' -- "$cur" ) ) + ;; + raid10) + COMPREPLY=( $( compgen -W 'n o p' -- "$cur" ) ) + ;; + faulty) + COMPREPLY=( $( compgen -W 'write-transient wt read-transient rt \ + write-persistent wp read-persistent rp write-all read-fixable \ + rf clear flush none' -- $cur ) ) + ;; + esac +} + +_mdadm_auto_flag() +{ + COMPREPLY=( $( compgen -W 'no yes md mdp part p' -- "$cur" ) ) +} + +_mdadm_update_flag() +{ + COMPREPLY=( $( compgen -W 'sparc2.2 summaries uuid name homehost resync \ + byteorder super-minor' -- "$cur" ) ) +} + + +_mdadm() +{ + local cur prev mode options split=false + + COMPREPLY=() + _get_comp_words_by_ref cur prev + + _split_longopt && split=true + + case $prev in + -c|--config|-b|--bitmap|--backup-file) + _filedir + return 0 + ;; + -l|--level) + _mdadm_raid_level + return 0 + ;; + -p|--layout|--parity) + _mdadm_raid_layout + return 0 + ;; + -a|--auto) + _mdadm_auto_flag + return 0 + ;; + -U|--update) + _mdadm_update_flag + return 0 + ;; + esac + + $split && return 0 + + options='--help --help-options --version --verbose --quiet \ + --brief --force --config --scan --metadata --homehost' + + if [[ "$cur" == -* ]]; then + if [[ $COMP_CWORD -eq 1 ]] ; then + COMPREPLY=( $( compgen -W "$options --assemble --build \ + --create --monitor --grow" -- "$cur" ) ) + else + case ${COMP_WORDS[COMP_CWORD-1]} in + -A|--assemble) + COMPREPLY=( $( compgen -W "$options --uuid \ + --super-minor --name --force --run \ + --no-degraded --auto --bitmap --backup-file \ + --update --auto-update-homehost" -- "$cur" ) ) + ;; + -B|-C|-G|--build|--create|--grow) + COMPREPLY=( $( 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" ) ) + ;; + -F|--follow|--monitor) + COMPREPLY=( $( compgen -W "$options --mail --program \ + --alert --syslog --delay --daemonise \ + --pid-file --oneshot --test" -- "$cur" ) ) + + ;; + /dev/*|--add|--fail|--remove) + COMPREPLY=( $( compgen -W "$options --add --re-add \ + --remove --fail --set-faulty" -- "$cur" ) ) + ;; + *) + COMPREPLY=( $( compgen -W "$options --query --detail \ + --examine --sparc2.2 --examine-bitmap --run \ + --stop --readonly --readwrite \ + --zero-superblock --test" -- "$cur" ) ) + ;; + esac + fi + else + cur=${cur:=/dev/} + _filedir + fi +} +complete -F _mdadm mdadm +} + +# Local variables: +# mode: shell-script +# sh-basic-offset: 4 +# sh-indent-comment: t +# indent-tabs-mode: nil +# End: +# ex: ts=4 sw=4 et filetype=sh |