File: bash-completion.sh

package info (click to toggle)
uftrace 0.6.0.20161014-1
  • links: PTS
  • area: main
  • in suites: stretch
  • size: 1,940 kB
  • ctags: 3,404
  • sloc: ansic: 24,586; python: 3,663; makefile: 585; asm: 242; sh: 135; cpp: 117
file content (27 lines) | stat: -rw-r--r-- 704 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
_uftrace () {
    local cur prev subcmd options uftrace_comp

    cur=${COMP_WORDS[COMP_CWORD]}
    prev=${COMP_WORDS[COMP_CWORD - 1]}

    COMPREPLY=()

    subcmds='record replay report live dump graph info recv'
    options=$(uftrace -? | awk '$1 ~ /--[a-z]/ { split($1, r, "="); print r[1] } \
                                $2 ~ /--[a-z]/ { split($2, r, "="); print r[1] }')

    uftrace_comp="${subcmds} ${options}"

    case $prev in
	-d|--data)
	    # complete directory name
	    COMPREPLY=($(compgen -d -- "${cur}"))
	    ;;
	*)
	    # complete subcommand or long option
	    COMPREPLY=($(compgen -W "${uftrace_comp}" -- "${cur}"))
	    ;;
    esac
    return 0
}
complete -F _uftrace uftrace