Compare commits

...

1 Commits

Author SHA1 Message Date
Abraham Toriz c50b765fe8 attempt at automated generation of completions 2023-03-11 19:31:38 -06:00
5 changed files with 692 additions and 20 deletions

10
Cargo.lock generated
View File

@ -134,6 +134,15 @@ dependencies = [
"textwrap 0.16.0",
]
[[package]]
name = "clap_complete"
version = "3.2.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3f7a2e0a962c45ce25afce14220bc24f9dade0a1787f185cecf96bfba7847cd8"
dependencies = [
"clap",
]
[[package]]
name = "clap_lex"
version = "0.2.4"
@ -943,6 +952,7 @@ dependencies = [
"atty",
"chrono",
"clap",
"clap_complete",
"csv",
"directories",
"hostname",

View File

@ -2,6 +2,10 @@
name = "t"
path = "src/bin/t.rs"
[[bin]]
name = "completions"
path = "src/bin/completions.rs"
[package]
name = "tiempo"
repository = "https://gitlab.com/categulario/tiempo-rs"
@ -30,6 +34,7 @@ serde_json = "1.0"
hostname = "0.3"
atty = "0.2"
timeago = "0.3"
clap_complete = "3"
[dependencies.clap]
version = "3"

View File

@ -1,16 +1,564 @@
#!/bin/bash
_tiempo ()
{
cur="${COMP_WORDS[COMP_CWORD]}"
cmd="${COMP_WORDS[1]}"
_tiempo() {
local i cur prev opts cmds
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
cmd=""
opts=""
if [[ ( $cmd = s* || $cmd = d* || $cmd = k* ) && "$COMP_CWORD" = 2 ]]; then
COMPREPLY=($(compgen -W "$(t l --all --flat)" $cur))
return
elif [[ "$COMP_CWORD" = 1 ]]; then
CMDS="archive backend configure display edit in kill list now out resume sheet week month"
COMPREPLY=($(compgen -W "$CMDS" $cur))
fi
for i in ${COMP_WORDS[@]}
do
case "${i}" in
"$1")
cmd="tiempo"
;;
archive)
cmd+="__archive"
;;
backend)
cmd+="__backend"
;;
configure)
cmd+="__configure"
;;
display)
cmd+="__display"
;;
edit)
cmd+="__edit"
;;
help)
cmd+="__help"
;;
in)
cmd+="__in"
;;
kill)
cmd+="__kill"
;;
list)
cmd+="__list"
;;
month)
cmd+="__month"
;;
now)
cmd+="__now"
;;
out)
cmd+="__out"
;;
resume)
cmd+="__resume"
;;
sheet)
cmd+="__sheet"
;;
today)
cmd+="__today"
;;
week)
cmd+="__week"
;;
yesterday)
cmd+="__yesterday"
;;
*)
;;
esac
done
case "${cmd}" in
tiempo)
opts="-h -V --help --version archive backend configure display today yesterday week month in resume out sheet list kill now edit help"
if [[ ${cur} == -* || ${COMP_CWORD} -eq 1 ]] ; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
fi
case "${prev}" in
*)
COMPREPLY=()
;;
esac
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
;;
tiempo__archive)
opts="-s -e -g -f -t -h --start --end --grep --fake --time --help <SHEET>"
if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
fi
case "${prev}" in
--start)
COMPREPLY=($(compgen -f "${cur}"))
return 0
;;
-s)
COMPREPLY=($(compgen -f "${cur}"))
return 0
;;
--end)
COMPREPLY=($(compgen -f "${cur}"))
return 0
;;
-e)
COMPREPLY=($(compgen -f "${cur}"))
return 0
;;
--grep)
COMPREPLY=($(compgen -f "${cur}"))
return 0
;;
-g)
COMPREPLY=($(compgen -f "${cur}"))
return 0
;;
--time)
COMPREPLY=($(compgen -f "${cur}"))
return 0
;;
-t)
COMPREPLY=($(compgen -f "${cur}"))
return 0
;;
*)
COMPREPLY=()
;;
esac
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
;;
tiempo__backend)
opts="-h --help"
if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
fi
case "${prev}" in
*)
COMPREPLY=()
;;
esac
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
;;
tiempo__configure)
opts="-h --round-in-seconds --database-file --append-notes-delimiter --formatter-search-paths --default-formatter --require-note --no-require-note --auto-checkout --no-auto-checkout --note-editor --week-start --interactive-entries --help"
if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
fi
case "${prev}" in
--round-in-seconds)
COMPREPLY=($(compgen -f "${cur}"))
return 0
;;
--database-file)
COMPREPLY=($(compgen -f "${cur}"))
return 0
;;
--append-notes-delimiter)
COMPREPLY=($(compgen -f "${cur}"))
return 0
;;
--formatter-search-paths)
COMPREPLY=($(compgen -f "${cur}"))
return 0
;;
--default-formatter)
COMPREPLY=($(compgen -f "${cur}"))
return 0
;;
--note-editor)
COMPREPLY=($(compgen -f "${cur}"))
return 0
;;
--week-start)
COMPREPLY=($(compgen -W "monday tuesday wednesday thursday friday saturday sunday" -- "${cur}"))
return 0
;;
--interactive-entries)
COMPREPLY=($(compgen -f "${cur}"))
return 0
;;
*)
COMPREPLY=()
;;
esac
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
;;
tiempo__display)
opts="-v -s -e -f -g -h --ids --start --end --format --grep --help <SHEET>"
if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
fi
case "${prev}" in
--start)
COMPREPLY=($(compgen -f "${cur}"))
return 0
;;
-s)
COMPREPLY=($(compgen -f "${cur}"))
return 0
;;
--end)
COMPREPLY=($(compgen -f "${cur}"))
return 0
;;
-e)
COMPREPLY=($(compgen -f "${cur}"))
return 0
;;
--format)
COMPREPLY=($(compgen -f "${cur}"))
return 0
;;
-f)
COMPREPLY=($(compgen -f "${cur}"))
return 0
;;
--grep)
COMPREPLY=($(compgen -f "${cur}"))
return 0
;;
-g)
COMPREPLY=($(compgen -f "${cur}"))
return 0
;;
*)
COMPREPLY=()
;;
esac
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
;;
tiempo__edit)
opts="-s -e -z -m -h --id --start --end --append --move --help <NOTE>"
if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
fi
case "${prev}" in
--id)
COMPREPLY=($(compgen -f "${cur}"))
return 0
;;
--start)
COMPREPLY=($(compgen -f "${cur}"))
return 0
;;
-s)
COMPREPLY=($(compgen -f "${cur}"))
return 0
;;
--end)
COMPREPLY=($(compgen -f "${cur}"))
return 0
;;
-e)
COMPREPLY=($(compgen -f "${cur}"))
return 0
;;
--move)
COMPREPLY=($(compgen -f "${cur}"))
return 0
;;
-m)
COMPREPLY=($(compgen -f "${cur}"))
return 0
;;
*)
COMPREPLY=()
;;
esac
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
;;
tiempo__help)
opts="<SUBCOMMAND>..."
if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
fi
case "${prev}" in
*)
COMPREPLY=()
;;
esac
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
;;
tiempo__in)
opts="-h --at --help <NOTE>"
if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
fi
case "${prev}" in
--at)
COMPREPLY=($(compgen -f "${cur}"))
return 0
;;
*)
COMPREPLY=()
;;
esac
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
;;
tiempo__kill)
opts="-l -h --id --last --help <SHEET>"
if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
fi
case "${prev}" in
--id)
COMPREPLY=($(compgen -f "${cur}"))
return 0
;;
*)
COMPREPLY=()
;;
esac
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
;;
tiempo__list)
opts="-a -f -h --all --flat --help"
if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
fi
case "${prev}" in
*)
COMPREPLY=()
;;
esac
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
;;
tiempo__month)
opts="-v -f -g -m -h --ids --format --grep --month --help <SHEET>"
if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
fi
case "${prev}" in
--format)
COMPREPLY=($(compgen -f "${cur}"))
return 0
;;
-f)
COMPREPLY=($(compgen -f "${cur}"))
return 0
;;
--grep)
COMPREPLY=($(compgen -f "${cur}"))
return 0
;;
-g)
COMPREPLY=($(compgen -f "${cur}"))
return 0
;;
--month)
COMPREPLY=($(compgen -W "this current last jan january feb february mar march apr april may jun june jul july aug august sep september oct october nov november dic december" -- "${cur}"))
return 0
;;
-m)
COMPREPLY=($(compgen -W "this current last jan january feb february mar march apr april may jun june jul july aug august sep september oct october nov november dic december" -- "${cur}"))
return 0
;;
*)
COMPREPLY=()
;;
esac
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
;;
tiempo__now)
opts="-h --help"
if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
fi
case "${prev}" in
*)
COMPREPLY=()
;;
esac
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
;;
tiempo__out)
opts="-h --at --help"
if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
fi
case "${prev}" in
--at)
COMPREPLY=($(compgen -f "${cur}"))
return 0
;;
*)
COMPREPLY=()
;;
esac
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
;;
tiempo__resume)
opts="-i -h --at --id --interactive --help"
if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
fi
case "${prev}" in
--at)
COMPREPLY=($(compgen -f "${cur}"))
return 0
;;
--id)
COMPREPLY=($(compgen -f "${cur}"))
return 0
;;
*)
COMPREPLY=()
;;
esac
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
;;
tiempo__sheet)
opts="-h --help <SHEET>"
if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
fi
case "${prev}" in
*)
COMPREPLY=()
;;
esac
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
;;
tiempo__today)
opts="-v -e -f -g -h --ids --end --format --grep --help <SHEET>"
if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
fi
case "${prev}" in
--end)
COMPREPLY=($(compgen -f "${cur}"))
return 0
;;
-e)
COMPREPLY=($(compgen -f "${cur}"))
return 0
;;
--format)
COMPREPLY=($(compgen -f "${cur}"))
return 0
;;
-f)
COMPREPLY=($(compgen -f "${cur}"))
return 0
;;
--grep)
COMPREPLY=($(compgen -f "${cur}"))
return 0
;;
-g)
COMPREPLY=($(compgen -f "${cur}"))
return 0
;;
*)
COMPREPLY=()
;;
esac
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
;;
tiempo__week)
opts="-v -e -f -g -h --ids --end --format --grep --help <SHEET>"
if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
fi
case "${prev}" in
--end)
COMPREPLY=($(compgen -f "${cur}"))
return 0
;;
-e)
COMPREPLY=($(compgen -f "${cur}"))
return 0
;;
--format)
COMPREPLY=($(compgen -f "${cur}"))
return 0
;;
-f)
COMPREPLY=($(compgen -f "${cur}"))
return 0
;;
--grep)
COMPREPLY=($(compgen -f "${cur}"))
return 0
;;
-g)
COMPREPLY=($(compgen -f "${cur}"))
return 0
;;
*)
COMPREPLY=()
;;
esac
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
;;
tiempo__yesterday)
opts="-v -f -g -h --ids --format --grep --help <SHEET>"
if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
fi
case "${prev}" in
--format)
COMPREPLY=($(compgen -f "${cur}"))
return 0
;;
-f)
COMPREPLY=($(compgen -f "${cur}"))
return 0
;;
--grep)
COMPREPLY=($(compgen -f "${cur}"))
return 0
;;
-g)
COMPREPLY=($(compgen -f "${cur}"))
return 0
;;
*)
COMPREPLY=()
;;
esac
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
;;
esac
if [[ ( $cmd = s* || $cmd = d* || $cmd = k* ) && "$COMP_CWORD" = 2 ]]; then
COMPREPLY=($(compgen -W "$(t l --all --flat)" $cur))
return
fi
}
complete -F _tiempo 't'
complete -F _tiempo -o bashdefault -o default t

View File

@ -1,16 +1,96 @@
# tiempo does not accept files as arguments
complete --command t --no-files
# define all subcommands
complete --command t -n "__fish_use_subcommand" -s h -l help -d -'Print help information'
complete --command t -n "__fish_use_subcommand" -s V -l version -d 'Print version information'
complete --command t -n "__fish_use_subcommand" -f -a "archive" -d 'Move entries to a hidden sheet (by default named \'_[SHEET]\') so they\'re out of the way.'
complete --command t -n "__fish_use_subcommand" -f -a "backend" -d 'Open an sqlite shell to the database.'
complete --command t -n "__fish_use_subcommand" -f -a "configure" -d 'Configure tiempo in-place. If no arguments are given it just prints the path to the config file in use.'
complete --command t -n "__fish_use_subcommand" -f -a "display" -d 'Display the current timesheet or a specific. Pass `all\' as SHEET to display all unarchived sheets or `full\' to display archived and unarchived sheets.'
complete --command t -n "__fish_use_subcommand" -f -a "today" -d 'Display entries that started today'
complete --command t -n "__fish_use_subcommand" -f -a "yesterday" -d 'Display entries that started yesterday'
complete --command t -n "__fish_use_subcommand" -f -a "week" -d 'Display entries starting last monday or later'
complete --command t -n "__fish_use_subcommand" -f -a "month" -d 'Display entries starting this month'
complete --command t -n "__fish_use_subcommand" -f -a "in" -d 'Start an activity in the current timesheet'
complete --command t -n "__fish_use_subcommand" -f -a "resume" -d 'Restart the timer for an entry. Defaults to the last active entry'
complete --command t -n "__fish_use_subcommand" -f -a "out" -d 'end the active entry in the current timesheet'
complete --command t -n "__fish_use_subcommand" -f -a "sheet" -d 'Change active timesheet or list existing timesheets'
complete --command t -n "__fish_use_subcommand" -f -a "list" -d 'List existing sheets'
complete --command t -n "__fish_use_subcommand" -f -a "kill" -d 'Delete an entry or an entire sheet'
complete --command t -n "__fish_use_subcommand" -f -a "now" -d 'Show all running entries'
complete --command t -n "__fish_use_subcommand" -f -a "edit" -d 'Edit an entry'
complete --command t -n "__fish_use_subcommand" -f -a "help" -d 'Print this message or the help of the given subcommand(s)'
complete --command t -n "__fish_seen_subcommand_from archive" -s s -l start -d 'Include entries that start on this date or later' -r
complete --command t -n "__fish_seen_subcommand_from archive" -s e -l end -d 'Include entries that start on this date or earlier' -r
complete --command t -n "__fish_seen_subcommand_from archive" -s g -l grep -d 'Only include entries whose note matches this regular expression' -r
complete --command t -n "__fish_seen_subcommand_from archive" -s t -l time -d 'Time in hours to archive. Archived time will be equal or less than this.' -r
complete --command t -n "__fish_seen_subcommand_from archive" -s f -l fake -d 'Don\'t actually archive the entries, just display them'
complete --command t -n "__fish_seen_subcommand_from archive" -s h -l help -d 'Print help information'
complete --command t -n "__fish_seen_subcommand_from backend" -s h -l help -d 'Print help information'
complete --command t -n "__fish_seen_subcommand_from configure" -l round-in-seconds -d 'The duration of time to use for rounding with the -r flag. Default: 900 (15 m)' -r
complete --command t -n "__fish_seen_subcommand_from configure" -l database-file -d 'The file path of the sqlite database' -r
complete --command t -n "__fish_seen_subcommand_from configure" -l append-notes-delimiter -d 'delimiter used when appending notes via t edit --append. Default: \' \' (space)' -r
complete --command t -n "__fish_seen_subcommand_from configure" -l formatter-search-paths -d 'comma separated directories to search for user defined fomatter classes' -r
complete --command t -n "__fish_seen_subcommand_from configure" -l default-formatter -d 'The format to use when display is invoked without a `--format` option. Default \'text\'' -r
complete --command t -n "__fish_seen_subcommand_from configure" -l note-editor -d 'Command to launch notes editor. Default: $EDITOR' -r
complete --command t -n "__fish_seen_subcommand_from configure" -l week-start -d 'The day of the week to use as the start of the week for t week. Default: monday' -r -f -a "{monday ,tuesday ,wednesday ,thursday ,friday ,saturday ,sunday }"
complete --command t -n "__fish_seen_subcommand_from configure" -l interactive-entries -d 'How many unique previous notes to show when selecting interactively' -r
complete --command t -n "__fish_seen_subcommand_from configure" -l require-note -d 'Prompt for a note if one isn\'t provided when checking in (default)'
complete --command t -n "__fish_seen_subcommand_from configure" -l no-require-note -d 'Entries can be created without notes'
complete --command t -n "__fish_seen_subcommand_from configure" -l auto-checkout -d 'Checkout of current running entry when starting a new one'
complete --command t -n "__fish_seen_subcommand_from configure" -l no-auto-checkout -d 'Starting a new entry fails if one is running (default)'
complete --command t -n "__fish_seen_subcommand_from configure" -s h -l help -d 'Print help information'
complete --command t -n "__fish_seen_subcommand_from display" -s s -l start -d 'Include entries that start on this date or later' -r
complete --command t -n "__fish_seen_subcommand_from display" -s e -l end -d 'Include entries that start on this date or earlier' -r
complete --command t -n "__fish_seen_subcommand_from display" -s f -l format -d 'The output format. Valid built-in formats are chart, text, ical, csv, json and ids. Documentation on defining custom formats can be found at https://tiempo.categulario.xyz or the man page included with the installation.' -r
complete --command t -n "__fish_seen_subcommand_from display" -s g -l grep -d 'Only include entries whose note matches this regular expression' -r
complete --command t -n "__fish_seen_subcommand_from display" -s v -l ids -d 'Print database ids (for use with edit)'
complete --command t -n "__fish_seen_subcommand_from display" -s h -l help -d 'Print help information'
complete --command t -n "__fish_seen_subcommand_from today" -s e -l end -d 'Include entries that start on this date or earlier' -r
complete --command t -n "__fish_seen_subcommand_from today" -s f -l format -d 'The output format. Valid built-in formats are chart, text, ical, csv, json and ids. Documentation on defining custom formats can be found at https://tiempo.categulario.xyz or the man page included with the installation.' -r
complete --command t -n "__fish_seen_subcommand_from today" -s g -l grep -d 'Only include entries whose note matches this regular expression' -r
complete --command t -n "__fish_seen_subcommand_from today" -s v -l ids -d 'Print database ids (for use with edit)'
complete --command t -n "__fish_seen_subcommand_from today" -s h -l help -d 'Print help information'
complete --command t -n "__fish_seen_subcommand_from yesterday" -s f -l format -d 'The output format. Valid built-in formats are chart, text, ical, csv, json and ids. Documentation on defining custom formats can be found at https://tiempo.categulario.xyz or the man page included with the installation.' -r
complete --command t -n "__fish_seen_subcommand_from yesterday" -s g -l grep -d 'Only include entries whose note matches this regular expression' -r
complete --command t -n "__fish_seen_subcommand_from yesterday" -s v -l ids -d 'Print database ids (for use with edit)'
complete --command t -n "__fish_seen_subcommand_from yesterday" -s h -l help -d 'Print help information'
complete --command t -n "__fish_seen_subcommand_from week" -s e -l end -d 'Include entries that start on this date or earlier' -r
complete --command t -n "__fish_seen_subcommand_from week" -s f -l format -d 'The output format. Valid built-in formats are chart, text, ical, csv, json and ids. Documentation on defining custom formats can be found at https://tiempo.categulario.xyz or the man page included with the installation.' -r
complete --command t -n "__fish_seen_subcommand_from week" -s g -l grep -d 'Only include entries whose note matches this regular expression' -r
complete --command t -n "__fish_seen_subcommand_from week" -s v -l ids -d 'Print database ids (for use with edit)'
complete --command t -n "__fish_seen_subcommand_from week" -s h -l help -d 'Print help information'
complete --command t -n "__fish_seen_subcommand_from month" -s f -l format -d 'The output format. Valid built-in formats are chart, text, ical, csv, json and ids. Documentation on defining custom formats can be found at https://tiempo.categulario.xyz or the man page included with the installation.' -r
complete --command t -n "__fish_seen_subcommand_from month" -s g -l grep -d 'Only include entries whose note matches this regular expression' -r
complete --command t -n "__fish_seen_subcommand_from month" -s m -l month -d 'Include entries of the specified month instead of the current month' -r -f -a "{this ,current ,last ,jan ,january ,feb ,february ,mar ,march ,apr ,april ,may ,jun ,june ,jul ,july ,aug ,august ,sep ,september ,oct ,october ,nov ,november ,dic ,december }"
complete --command t -n "__fish_seen_subcommand_from month" -s v -l ids -d 'Print database ids (for use with edit)'
complete --command t -n "__fish_seen_subcommand_from month" -s h -l help -d 'Print help information'
complete --command t -n "__fish_seen_subcommand_from in" -l at -d 'Use this time instead of now' -r
complete --command t -n "__fish_seen_subcommand_from in" -s h -l help -d 'Print help information'
complete --command t -n "__fish_seen_subcommand_from resume" -l at -d 'Use this time instead of now' -r
complete --command t -n "__fish_seen_subcommand_from resume" -l id -d 'Use entry with ID instead of the last entry' -r
complete --command t -n "__fish_seen_subcommand_from resume" -s i -l interactive -d 'Choose an entry of the (unique) last N interactively'
complete --command t -n "__fish_seen_subcommand_from resume" -s h -l help -d 'Print help information'
complete --command t -n "__fish_seen_subcommand_from out" -l at -d 'Use this time instead of now' -r
complete --command t -n "__fish_seen_subcommand_from out" -s h -l help -d 'Print help information'
complete --command t -n "__fish_seen_subcommand_from sheet" -s h -l help -d 'Print help information'
complete --command t -n "__fish_seen_subcommand_from list" -s a -l all -d 'List archive sheets also'
complete --command t -n "__fish_seen_subcommand_from list" -s f -l flat -d 'show only the sheet names'
complete --command t -n "__fish_seen_subcommand_from list" -s h -l help -d 'Print help information'
complete --command t -n "__fish_seen_subcommand_from kill" -l id -d 'Delete entry with this ID instead of sheet' -r
complete --command t -n "__fish_seen_subcommand_from kill" -s l -l last -d 'Delete the last entry of the current sheet'
complete --command t -n "__fish_seen_subcommand_from kill" -s h -l help -d 'Print help information'
complete --command t -n "__fish_seen_subcommand_from now" -s h -l help -d 'Print help information'
complete --command t -n "__fish_seen_subcommand_from edit" -l id -d 'Edit entry with this ID instead of the last one in the current sheet' -r
complete --command t -n "__fish_seen_subcommand_from edit" -s s -l start -d 'Set this as the start time' -r
complete --command t -n "__fish_seen_subcommand_from edit" -s e -l end -d 'Set this as the end time' -r
complete --command t -n "__fish_seen_subcommand_from edit" -s m -l move -d 'Move entry to another sheet' -r
complete --command t -n "__fish_seen_subcommand_from edit" -s z -l append -d 'Append to the current note instead of replacing it. The delimiter between appended notes is configurable (see configure)'
complete --command t -n "__fish_seen_subcommand_from edit" -s h -l help -d 'Print help information'
set -l sheetcommandslong display kill sheet week month
set -l sheetcommandsshort d k s w m
set -l sheetcommandsall $sheetcommandslong $sheetcommandsshort
set -l commandslong archive backend configure edit in list now out resume
set -l commandsshort a b c e i l n o r
set -l subcommands $sheetcommandslong $commandslong $sheetcommandsshort $commandsshort
# add subcommands
complete --command t --condition "not __fish_seen_subcommand_from $subcommands" -a "$subcommands"
# complete sheet name
complete --command t --condition "__fish_seen_subcommand_from $sheetcommandsall" -a "(t l --all --flat)"

29
src/bin/completions.rs Normal file
View File

@ -0,0 +1,29 @@
use clap::{Command, Arg, value_parser, ArgAction};
use clap_complete::{generate, Generator, Shell};
use std::io;
use tiempo::cli::make_cli;
fn print_completions<G: Generator>(gen: G, cmd: &mut Command) {
generate(gen, cmd, cmd.get_name().to_string(), &mut io::stdout());
}
fn main() {
let command = Command::new("example")
.arg(
Arg::new("generator")
.long("generate")
.action(ArgAction::Set)
.value_parser(value_parser!(Shell)),
);
let matches = command.get_matches();
if let Some(generator) = matches.get_one::<Shell>("generator").copied() {
let mut cmd = make_cli();
eprintln!("Generating completion file for {}...", generator);
print_completions(generator, &mut cmd);
} else {
eprintln!("Specified generator does not exist");
}
}