| 1 |
_cmd_list=( |
| 2 |
'install' |
| 3 |
'uninstall' |
| 4 |
'test' |
| 5 |
'report' |
| 6 |
'version' |
| 7 |
) |
| 8 |
|
| 9 |
_general_opts=( |
| 10 |
) |
| 11 |
|
| 12 |
_report_opts=( |
| 13 |
'--since' |
| 14 |
'--until' |
| 15 |
'--report-file' |
| 16 |
'--format' |
| 17 |
'--report-debug' |
| 18 |
) |
| 19 |
|
| 20 |
_test_opts=( |
| 21 |
'--wait' |
| 22 |
'--count' |
| 23 |
'--duration' |
| 24 |
'--report-file' |
| 25 |
'--format' |
| 26 |
'--force' |
| 27 |
'--logind' |
| 28 |
'--tool-debug' |
| 29 |
'--report-debug' |
| 30 |
) |
| 31 |
|
| 32 |
_format_opts=( |
| 33 |
'md' |
| 34 |
'html' |
| 35 |
'txt' |
| 36 |
) |
| 37 |
|
| 38 |
_show_test_opts() |
| 39 |
{ |
| 40 |
COMPREPLY+=( $(compgen -W '${_test_opts[@]}' -- "$cur") ) |
| 41 |
} |
| 42 |
|
| 43 |
_show_report_opts() |
| 44 |
{ |
| 45 |
COMPREPLY+=( $(compgen -W '${_report_opts[@]}' -- "$cur") ) |
| 46 |
} |
| 47 |
|
| 48 |
_show_format_completion() |
| 49 |
{ |
| 50 |
COMPREPLY+=( $(compgen -W '${_format_opts[@]}' -- "$cur") ) |
| 51 |
} |
| 52 |
|
| 53 |
_amd_s2idle() |
| 54 |
{ |
| 55 |
local cur prev command arg args |
| 56 |
COMPREPLY=() |
| 57 |
_get_comp_words_by_ref cur prev |
| 58 |
_get_first_arg |
| 59 |
_count_args |
| 60 |
|
| 61 |
case $prev in |
| 62 |
--log|--duration|--count|--wait|--since|--report-file) |
| 63 |
return 0 |
| 64 |
;; |
| 65 |
--format) |
| 66 |
_show_format_completion |
| 67 |
return 0 |
| 68 |
;; |
| 69 |
esac |
| 70 |
case $arg in |
| 71 |
test) |
| 72 |
_show_test_opts |
| 73 |
;; |
| 74 |
report) |
| 75 |
_show_report_opts |
| 76 |
;; |
| 77 |
|
| 78 |
*) |
| 79 |
#find first command |
| 80 |
if [[ "$args" = "1" ]]; then |
| 81 |
COMPREPLY=( $(compgen -W '${_cmd_list[@]}' -- "$cur") ) |
| 82 |
fi |
| 83 |
;; |
| 84 |
esac |
| 85 |
|
| 86 |
return 0 |
| 87 |
} |
| 88 |
|
| 89 |
complete -F _amd_s2idle amd-s2idle |