diff options
Diffstat (limited to 'completions/fio')
-rw-r--r-- | completions/fio | 115 |
1 files changed, 86 insertions, 29 deletions
diff --git a/completions/fio b/completions/fio index f81a4da..7fbcdd4 100644 --- a/completions/fio +++ b/completions/fio @@ -1,90 +1,147 @@ # fio(1) completion -*- shell-script -*- -_fio() +_comp_cmd_fio__compgen_engines() { - local cur prev words cword split - _init_completion -s || return + _comp_compgen_split -l -- "$("$1" --enghelp 2>/dev/null | command sed -ne '/^[[:space:]]/p'))" +} +_comp_cmd_fio() +{ + local cur prev words cword was_split comp_args + _comp_initialize -s -- "$@" || return + + local REPLY case $prev in --help | --version) return ;; --debug) - local prefix= - [[ $cur == *,* ]] && prefix="${cur%,*}," - COMPREPLY=($(compgen -W "process file io mem blktrace verify - random parse diskutil job mutex profile time net rate compress - steadystate helperthread" -- "${cur##*,}")) - ((${#COMPREPLY[@]} == 1)) && COMPREPLY=(${COMPREPLY/#/$prefix}) + local opts=$("$1" --debug=help 2>/dev/null) + opts=${opts##*:} + _comp_delimited , -W "${opts//,/ }" return ;; --output-format) - COMPREPLY=($(compgen -W "terse json json+ normal" -- "$cur")) + _comp_compgen -- -W "terse json json+ normal" return ;; --terse-version) - COMPREPLY=($(compgen -W "2 3" -- "$cur")) + _comp_compgen -- -W "2 3 4 5" + return + ;; + --crctest) + _comp_compgen_split -- "$("$1" --crctest=nonexistent 2>/dev/null)" return ;; --cmdhelp) - # TODO more commands? - COMPREPLY=($(compgen -W "all" -- "$cur")) + _comp_compgen_split -- "$("$1" --cmdhelp=all 2>/dev/null | _comp_awk '{print $1}') all" return ;; --enghelp) - # TODO print ioengine help, or list available ioengines - # TODO engine,help arg + _comp_cmd_fio__compgen_engines "$1" return ;; --eta) - COMPREPLY=($(compgen -W "always never auto" -- "$cur")) + _comp_compgen -- -W "always never auto" return ;; --daemonize) - _filedir pid + _comp_compgen_filedir pid return ;; --client) - _known_hosts_real -- "$cur" + _comp_compgen_known_hosts -- "$cur" return ;; --remote-config) - _filedir job + _comp_compgen_filedir '@(fio|job)' return ;; --idle-prof) - COMPREPLY=($(compgen -W "system percpu calibrate" -- "$cur")) + _comp_compgen -- -W "system percpu calibrate" return ;; --inflate-log) - _filedir log + _comp_compgen_filedir log return ;; --trigger-file) - _filedir + _comp_compgen_filedir return ;; --trigger | --trigger-remote) - compopt -o filenames - COMPREPLY=($(compgen -c -- "$cur")) + _comp_compgen_commands return ;; --aux-path) - _filedir -d + _comp_compgen_filedir -d return ;; + --ioengine) + _comp_cmd_fio__compgen_engines "$1" + return + ;; + --exec_postrun | --exec_prerun) + _comp_compgen_commands + return + ;; + --uid) + _comp_compgen_uids + return + ;; + --gid) + _comp_compgen_gids + return + ;; + --?*) + local -a cmdhelp + _comp_split -l cmdhelp "$("$1" --cmdhelp="${prev#--}" 2>/dev/null)" + case ${cmdhelp[*]-} in + *"showing closest match"*) + # ignore + ;; + *" type: boolean "* | *" type: empty or boolean "*) + _comp_compgen -- -W '0 1' + return + ;; + *" valid values:"*) + # For example, for --kb_base=: + # valid values: 1024 [...] + # : 1000 [...] + local line="" in_values="" + REPLY=() + for line in "${cmdhelp[@]}"; do + if [[ $in_values ]]; then + if [[ $line =~ ^[[:space:]]*:[[:space:]]*([^[:space:]]+) ]]; then + REPLY+=("${BASH_REMATCH[1]}") + else + break + fi + elif [[ $line =~ ^[[:space:]]*valid\ values:[[:space:]]*([^[:space:]]+) ]]; then + in_values=set + REPLY+=("${BASH_REMATCH[1]}") + fi + done + _comp_compgen -- -W '"${REPLY[@]}"' + return + ;; + esac + # else fallthrough + ;; esac - $split && return + [[ $was_split ]] && return if [[ $cur == -* ]]; then - COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + _comp_compgen_help + _comp_compgen -a split -- "$("$1" --cmdhelp=all 2>/dev/null | + _comp_awk '{printf "--%s=\n", $1}')" [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return fi - _filedir job + _comp_compgen_filedir '@(fio|job)' } && - complete -F _fio fio + complete -F _comp_cmd_fio fio # ex: filetype=sh |