[go: up one dir, main page]

File: bash-completion.sh

package info (click to toggle)
uftrace 0.18.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,356 kB
  • sloc: ansic: 49,770; python: 11,181; asm: 837; makefile: 769; sh: 637; cpp: 627; javascript: 191
file content (35 lines) | stat: -rw-r--r-- 1,010 bytes parent folder | download | duplicates (3)
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
28
29
30
31
32
33
34
35
_uftrace () {
    local cur prev subcmds options uftrace_comp

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

    COMPREPLY=()

    subcmds='record replay report live dump graph info recv script tui'
    options=$(uftrace -h | awk '$1 ~ /--[a-z]/ { split($1, r, "="); print r[1] } \
                                $2 ~ /--[a-z]/ { split($2, r, "="); print r[1] }')
    demangle='full simple no'
    sort_key='total self call avg min max'

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

    case $prev in
	-d|--data|--diff|-L|--libmcount-path)
	    # complete directory name
	    COMPREPLY=($(compgen -d -- "${cur}"))
	    ;;
	--demangle)
	    COMPREPLY=($(compgen -W "${demangle}" -- "${cur}"))
	    ;;
	-s|--sort)
	    COMPREPLY=($(compgen -W "${sort_key}" -- "${cur}"))
	    ;;
	*)
	    # complete subcommand, long option or (executable) filename
	    COMPREPLY=($(compgen -f -W "${uftrace_comp}" -- "${cur}"))
	    ;;
    esac
    return 0
}
complete -o filenames -F _uftrace uftrace