Skip to content

Commit

Permalink
cli: Add bash/fish/zsh completions for -D/-W/--theme/--unknownb/--unk…
Browse files Browse the repository at this point in the history
…nownc
  • Loading branch information
vincentdephily committed Jan 17, 2025
1 parent 2067e32 commit 037cc1b
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 12 deletions.
31 changes: 23 additions & 8 deletions completion.bash
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ _emlop() {

case "${cmd}" in
emlop)
opts="log predict stats accuracy -f -t -H -o -F -v -h -V --from --to --header --showskip --duration --date --utc --color --output --logfile --help --version"
opts="log predict stats accuracy -f -t -H -o -F -v -h -V --from --to --header --showskip --duration --date --utc --color --theme --output --logfile --help --version"
if [[ ${cur} == -* ]] ; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
Expand All @@ -51,6 +51,9 @@ _emlop() {
--color)
COMPREPLY=($(compgen -W "yes no auto" "${cur}"))
;;
--theme)
COMPREPLY=($(compgen -W "merge: binmerge: unmerge: sync: duration: qmark: skip:" "${cur}"))
;;
--output|-o)
COMPREPLY=($(compgen -W "tab columns auto" "${cur}"))
;;
Expand All @@ -64,7 +67,7 @@ _emlop() {
return 0
;;
emlop__accuracy)
opts="[search]... -e -s -n -f -t -H -o -F -v -h --exact --show --last --avg --limit --from --to --header --showskip --duration --date --utc --color --output --logfile --help"
opts="[search]... -e -s -n -f -t -H -o -F -v -h --exact --show --last --avg --limit --from --to --header --showskip --duration --date --utc --color --theme --output --logfile --help"
if [[ ${cur} == -* ]] ; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
Expand All @@ -88,6 +91,9 @@ _emlop() {
--color)
COMPREPLY=($(compgen -W "yes no auto" "${cur}"))
;;
--theme)
COMPREPLY=($(compgen -W "merge: binmerge: unmerge: sync: duration: qmark: skip:" "${cur}"))
;;
--output|-o)
COMPREPLY=($(compgen -W "tab columns auto" "${cur}"))
;;
Expand Down Expand Up @@ -117,7 +123,7 @@ _emlop() {
return 0
;;
emlop__log)
opts=" [search]... -N -n -s -e -f -t -H -o -F -v -h --starttime --first --last --show --exact --from --to --header --showskip --duration --date --utc --color --output --logfile --help"
opts="[search]... -N -n -s -e -f -t -H -o -F -v -h --starttime --first --last --show --exact --from --to --header --showskip --duration --date --utc --color --theme --output --logfile --help"
if [[ ${cur} == -* ]] ; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
Expand All @@ -141,6 +147,9 @@ _emlop() {
--color)
COMPREPLY=($(compgen -W "yes no auto" "${cur}"))
;;
--theme)
COMPREPLY=($(compgen -W "merge: binmerge: unmerge: sync: duration: qmark: skip:" "${cur}"))
;;
--output|-o)
COMPREPLY=($(compgen -W "tab columns auto" "${cur}"))
;;
Expand All @@ -167,7 +176,7 @@ _emlop() {
return 0
;;
emlop__predict)
opts="-s -N -n -f -t -H -o -F -v -h --show --first --last --tmpdir --resume --unknown --avg --limit --from --to --header --showskip --duration --date --utc --color --output --pdepth --pwidth --logfile --help"
opts="-s -N -n -W -D -f -t -H -o -F -v -h --show --first --last --tmpdir --resume --unknownc --unknownb --avg --limit --from --to --header --showskip --duration --date --utc --color --theme --output --pdepth --pwidth --logfile --help"
if [[ ${cur} == -* ]] ; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
Expand All @@ -191,10 +200,13 @@ _emlop() {
--color)
COMPREPLY=($(compgen -W "yes no auto" "${cur}"))
;;
--pwidth)
--theme)
COMPREPLY=($(compgen -W "merge: binmerge: unmerge: sync: duration: qmark: skip:" "${cur}"))
;;
--pwidth|-W)
COMPREPLY=($(compgen -W "10 20 40 80 160" "${cur}"))
;;
--pdepth)
--pdepth|-D)
COMPREPLY=($(compgen -W "0 1 3 5 7 99" "${cur}"))
;;
--output|-o)
Expand All @@ -215,7 +227,7 @@ _emlop() {
--resume)
COMPREPLY=($(compgen -W "auto either main backup no" -- "${cur}"))
;;
--unknown)
--unknownc|--unknownb)
COMPREPLY=($(compgen -W "0 5 10 20 60" "${cur}"))
;;
--avg)
Expand All @@ -231,7 +243,7 @@ _emlop() {
return 0
;;
emlop__stats)
opts="[search]... -s -g -e -f -t -H -o -F -v -h --show --groupby --exact --avg --limit --from --to --header --showskip --duration --date --utc --color --output --logfile --help"
opts="[search]... -s -g -e -f -t -H -o -F -v -h --show --groupby --exact --avg --limit --from --to --header --showskip --duration --date --utc --color --theme --output --logfile --help"
if [[ ${cur} == -* ]] ; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
Expand All @@ -255,6 +267,9 @@ _emlop() {
--color)
COMPREPLY=($(compgen -W "yes no auto" "${cur}"))
;;
--theme)
COMPREPLY=($(compgen -W "merge: binmerge: unmerge: sync: duration: qmark: skip:" "${cur}"))
;;
--output|-o)
COMPREPLY=($(compgen -W "tab columns auto" "${cur}"))
;;
Expand Down
8 changes: 5 additions & 3 deletions completion.fish
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ complete -c emlop -l duration -d 'Output durations in different formats' -x -a "
complete -c emlop -l date -d 'Output dates in different formats' -x -a "ymd ymdhms ymdhmso rfc3339 rfc2822 compact unix"
complete -c emlop -l utc -d 'Parse/display dates in UTC instead of local time' -f -a "yes no"
complete -c emlop -l color -d 'Enable color (yes/no/auto)' -f -a "{yes Enabled,no Disabled,auto 'Enabled on terminal'}"
complete -c emlop -l theme -d 'Set terminal colors' -f -a "merge: binmerge: unmerge: sync: duration: qmark: skip:"
complete -c emlop -s o -l output -d 'Ouput format' -x -a "columns tab auto"
complete -c emlop -s F -l logfile -d 'Location of emerge log file' -r -F
complete -c emlop -s v -x -a "{ 'Show warnings',v 'Show info',vv 'Show debug',vvv 'Show trace'}" -d 'Increase verbosity'
Expand All @@ -32,11 +33,12 @@ complete -c emlop -n "__fish_seen_subcommand_from predict" -s N -l first -d 'Sho
complete -c emlop -n "__fish_seen_subcommand_from predict" -s n -l last -d 'Show only the last <num> entries' -f -a "{ 'Show only last entry',5 'Show only last 5 entries',10 'Show only last 10 entries'}"
complete -c emlop -n "__fish_seen_subcommand_from predict" -l tmpdir -d 'Location of portage tmpdir' -x -a "(__fish_complete_directories '$1')"
complete -c emlop -n "__fish_seen_subcommand_from predict" -l resume -d 'Use main, backup, either, or no portage resume list' -f -a "{auto '',either '',main '',backup '',no ''}"
complete -c emlop -n "__fish_seen_subcommand_from predict" -l unknown -d 'Assume unkown packages take <secs> seconds to merge' -x -a "0 5 10 20 60"
complete -c emlop -n "__fish_seen_subcommand_from predict" -l unknownb -d 'Assume unkown binary packages take <secs> seconds to merge' -x -a "0 5 10 20 60"
complete -c emlop -n "__fish_seen_subcommand_from predict" -l unknownc -d 'Assume unkown compiled packages take <secs> seconds to merge' -x -a "0 5 10 20 60"
complete -c emlop -n "__fish_seen_subcommand_from predict" -l avg -d 'Select function used to predict durations' -x -a "arith median weighted-arith weighted-median"
complete -c emlop -n "__fish_seen_subcommand_from predict" -l limit -d 'Use the last <num> merge times to predict durations' -x -a "1 5 20 999"
complete -c emlop -n "__fish_seen_subcommand_from predict" -l pwidth -d 'Maximum width of emerge proces comandline' -x -a "10 20 40 80 160"
complete -c emlop -n "__fish_seen_subcommand_from predict" -l pdepth -d 'Maximum depth of emerge proces tree' -x -a "0 1 3 5 7 99"
complete -c emlop -n "__fish_seen_subcommand_from predict" -s W -l pwidth -d 'Maximum width of emerge proces comandline' -x -a "10 20 40 80 160"
complete -c emlop -n "__fish_seen_subcommand_from predict" -s D -l pdepth -d 'Maximum depth of emerge proces tree' -x -a "0 1 3 5 7 99"

complete -c emlop -n "__fish_seen_subcommand_from stats" -s s -l show -d 'Show (p)ackages, (t)otals, (s)yncs, and/or (a)ll' -x -a "ptsa"
complete -c emlop -n "__fish_seen_subcommand_from stats" -s g -l groupby -d 'Group by (y)ear, (m)onth, (w)eek, (d)ay, (n)one' -x -a "year month week day none"
Expand Down
10 changes: 9 additions & 1 deletion completion.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ _emlop() {
'--date=[Output dates in different formats]:format: ' \
'--utc=[Parse/display dates in UTC instead of local time]' \
'--color=[Enable color (yes/no/auto)]' \
'--theme=[Set terminal colors]' \
'-o+[Ouput format (columns/tab/auto)]:format: ' \
'--output=[Ouput format (columns/tab/auto)]:format: ' \
'-F+[Location of emerge log file]:file: ' \
Expand Down Expand Up @@ -53,6 +54,7 @@ _emlop() {
'--date=[Output dates in different formats]:format: ' \
'--utc=[Parse/display dates in UTC instead of local time]' \
'--color=[Enable color (yes/no/auto)]' \
'--theme=[Set terminal colors]' \
'-o+[Ouput format (columns/tab/auto)]:format: ' \
'--output=[Ouput format (columns/tab/auto)]:format: ' \
'-F+[Location of emerge log file]:file: ' \
Expand All @@ -74,7 +76,8 @@ _emlop() {
'--last=[Show only the last <num> entries]' \
'*--tmpdir=[Location of portage tmpdir]:dir:_files' \
'--resume=[Use main, backup, either, or no portage resume list]' \
'--unknown=[Assume unkown packages take <secs> seconds to merge]:secs: ' \
'--unknownb=[Assume unkown binary packages take <secs> seconds to merge]:secs: ' \
'--unknownc=[Assume unkown compiled packages take <secs> seconds to merge]:secs: ' \
'--avg=[Select function used to predict durations]:fn: ' \
'--limit=[Use the last <num> merge times to predict durations]:num: ' \
'-f+[Only parse log entries after <date>]:date: ' \
Expand All @@ -88,9 +91,12 @@ _emlop() {
'--date=[Output dates in different formats]:format: ' \
'--utc=[Parse/display dates in UTC instead of local time]' \
'--color=[Enable color (yes/no/auto)]' \
'--theme=[Set terminal colors]' \
'-o+[Ouput format (columns/tab/auto)]:format: ' \
'--output=[Ouput format (columns/tab/auto)]:format: ' \
'-W+[Maximum width of emerge proces comandline]'
'--pwidth=[Maximum width of emerge proces comandline]'
'-D+[Maximum depth of emerge proces tree]'
'--pdepth=[Maximum depth of emerge proces tree]'
'-F+[Location of emerge log file]:file: ' \
'--logfile=[Location of emerge log file]:file: ' \
Expand All @@ -117,6 +123,7 @@ _emlop() {
'--date=[Output dates in different formats]:format: ' \
'--utc=[Parse/display dates in UTC instead of local time]' \
'--color=[Enable color (yes/no/auto)]' \
'--theme=[Set terminal colors]' \
'-o+[Ouput format (columns/tab/auto)]:format: ' \
'--output=[Ouput format (columns/tab/auto)]:format: ' \
'-F+[Location of emerge log file]:file: ' \
Expand Down Expand Up @@ -147,6 +154,7 @@ _emlop() {
'--date=[Output dates in different formats]:format: ' \
'--utc=[Parse/display dates in UTC instead of local time]' \
'--color=[Enable color (yes/no/auto)]' \
'--theme=[Set terminal colors]' \
'-o+[Ouput format (columns/tab/auto)]:format: ' \
'--output=[Ouput format (columns/tab/auto)]:format: ' \
'-F+[Location of emerge log file]:file: ' \
Expand Down

0 comments on commit 037cc1b

Please sign in to comment.