2023-08-12 18:16:24 +00:00
function __fish -timesheets-available-projects
2023-09-26 17:04:02 +00:00
grep 'account Project:.*' " $TIMESHEET_LEDGER_HOME /config/accounts.dat " | cut -f2 -d ' '
2023-08-12 18:16:24 +00:00
end
2023-08-12 18:54:10 +00:00
function __fish -timesheets-running-projects
cat " $TIMESHEET_LEDGER_HOME /timesheets/ $( date +%Y).journal " | grep -v ';' | awk '{ last[$4] = $1 } END { for (i in last) { if (last[i] == "i") { print i } } }'
end
2023-08-12 18:16:24 +00:00
function __fish -timesheets-existing-comments
ledger -f " $TIMESHEET_LEDGER_HOME /main.journal " payees ^ Project
end
function __fish_timesheets_arg_number -a number
set -l cmd ( commandline -opc )
test ( count $cmd ) -eq $number
end
complete -c t -x -l help -s h -d "print usage help"
complete -c t -x -l verbose -s v -d "verbose output"
complete -c t -x -n "__fish_use_subcommand" -a in -d "start tracking time for a project"
complete -c t -x -n "__fish_use_subcommand" -a out -d "stop tracking time for a project"
complete -c t -x -n "__fish_use_subcommand" -a bal -d "print current balance"
# In
complete -c t -x -n "__fish_seen_subcommand_from in" -n "__fish_timesheets_arg_number 2" -a '(__fish-timesheets-available-projects)'
complete -c t -x -n "__fish_seen_subcommand_from in" -n "__fish_timesheets_arg_number 3" -a '(__fish-timesheets-existing-comments)'
# Out
2023-08-12 18:54:10 +00:00
complete -c t -x -n "__fish_seen_subcommand_from out" -a '(__fish-timesheets-running-projects)'
2023-08-12 18:16:24 +00:00
# Bal
complete -c t -x -n "__fish_seen_subcommand_from bal" -a '(__fish-timesheets-available-projects)'