#compdef streamd

autoload -U is-at-least

_streamd() {
    typeset -A opt_args
    typeset -a _arguments_options
    local ret=1

    if is-at-least 5.2; then
        _arguments_options=(-s -S -C)
    else
        _arguments_options=(-s -C)
    fi

    local context curcontext="$curcontext" state line
    _arguments "${_arguments_options[@]}" : \
'-h[Print help]' \
'--help[Print help]' \
'-V[Print version]' \
'--version[Print version]' \
":: :_streamd_commands" \
"*::: :->streamd" \
&& ret=0
    case $state in
    (streamd)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:streamd-command-$line[1]:"
        case $line[1] in
            (new)
_arguments "${_arguments_options[@]}" : \
'-h[Print help]' \
'--help[Print help]' \
&& ret=0
;;
(todo)
_arguments "${_arguments_options[@]}" : \
'--show-future[Show tasks with dates in the future]' \
'-h[Print help]' \
'--help[Print help]' \
":: :_streamd__todo_commands" \
"*::: :->todo" \
&& ret=0

    case $state in
    (todo)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:streamd-todo-command-$line[1]:"
        case $line[1] in
            (edit)
_arguments "${_arguments_options[@]}" : \
'-h[Print help]' \
'--help[Print help]' \
':number -- Task number to edit:_default' \
&& ret=0
;;
(done)
_arguments "${_arguments_options[@]}" : \
'-h[Print help]' \
'--help[Print help]' \
':number -- Task number to mark as done:_default' \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" : \
":: :_streamd__todo__help_commands" \
"*::: :->help" \
&& ret=0

    case $state in
    (help)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:streamd-todo-help-command-$line[1]:"
        case $line[1] in
            (edit)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(done)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
        esac
    ;;
esac
;;
        esac
    ;;
esac
;;
(edit)
_arguments "${_arguments_options[@]}" : \
'-h[Print help]' \
'--help[Print help]' \
'::number -- Position of the file to edit (0 = most recent, negative = from oldest):_default' \
&& ret=0
;;
(timesheet)
_arguments "${_arguments_options[@]}" : \
'-h[Print help]' \
'--help[Print help]' \
&& ret=0
;;
(completions)
_arguments "${_arguments_options[@]}" : \
'-h[Print help]' \
'--help[Print help]' \
':shell -- Shell to generate completions for:(bash elvish fish powershell zsh)' \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" : \
":: :_streamd__help_commands" \
"*::: :->help" \
&& ret=0

    case $state in
    (help)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:streamd-help-command-$line[1]:"
        case $line[1] in
            (new)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(todo)
_arguments "${_arguments_options[@]}" : \
":: :_streamd__help__todo_commands" \
"*::: :->todo" \
&& ret=0

    case $state in
    (todo)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:streamd-help-todo-command-$line[1]:"
        case $line[1] in
            (edit)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(done)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
        esac
    ;;
esac
;;
(edit)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(timesheet)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(completions)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
        esac
    ;;
esac
;;
        esac
    ;;
esac
}

(( $+functions[_streamd_commands] )) ||
_streamd_commands() {
    local commands; commands=(
'new:Create a new stream file' \
'todo:Display open tasks' \
'edit:Edit a stream file by position' \
'timesheet:Display extracted timesheets' \
'completions:Generate shell completions' \
'help:Print this message or the help of the given subcommand(s)' \
    )
    _describe -t commands 'streamd commands' commands "$@"
}
(( $+functions[_streamd__completions_commands] )) ||
_streamd__completions_commands() {
    local commands; commands=()
    _describe -t commands 'streamd completions commands' commands "$@"
}
(( $+functions[_streamd__edit_commands] )) ||
_streamd__edit_commands() {
    local commands; commands=()
    _describe -t commands 'streamd edit commands' commands "$@"
}
(( $+functions[_streamd__help_commands] )) ||
_streamd__help_commands() {
    local commands; commands=(
'new:Create a new stream file' \
'todo:Display open tasks' \
'edit:Edit a stream file by position' \
'timesheet:Display extracted timesheets' \
'completions:Generate shell completions' \
'help:Print this message or the help of the given subcommand(s)' \
    )
    _describe -t commands 'streamd help commands' commands "$@"
}
(( $+functions[_streamd__help__completions_commands] )) ||
_streamd__help__completions_commands() {
    local commands; commands=()
    _describe -t commands 'streamd help completions commands' commands "$@"
}
(( $+functions[_streamd__help__edit_commands] )) ||
_streamd__help__edit_commands() {
    local commands; commands=()
    _describe -t commands 'streamd help edit commands' commands "$@"
}
(( $+functions[_streamd__help__help_commands] )) ||
_streamd__help__help_commands() {
    local commands; commands=()
    _describe -t commands 'streamd help help commands' commands "$@"
}
(( $+functions[_streamd__help__new_commands] )) ||
_streamd__help__new_commands() {
    local commands; commands=()
    _describe -t commands 'streamd help new commands' commands "$@"
}
(( $+functions[_streamd__help__timesheet_commands] )) ||
_streamd__help__timesheet_commands() {
    local commands; commands=()
    _describe -t commands 'streamd help timesheet commands' commands "$@"
}
(( $+functions[_streamd__help__todo_commands] )) ||
_streamd__help__todo_commands() {
    local commands; commands=(
'edit:Edit a task by its number' \
'done:Mark a task as done' \
    )
    _describe -t commands 'streamd help todo commands' commands "$@"
}
(( $+functions[_streamd__help__todo__done_commands] )) ||
_streamd__help__todo__done_commands() {
    local commands; commands=()
    _describe -t commands 'streamd help todo done commands' commands "$@"
}
(( $+functions[_streamd__help__todo__edit_commands] )) ||
_streamd__help__todo__edit_commands() {
    local commands; commands=()
    _describe -t commands 'streamd help todo edit commands' commands "$@"
}
(( $+functions[_streamd__new_commands] )) ||
_streamd__new_commands() {
    local commands; commands=()
    _describe -t commands 'streamd new commands' commands "$@"
}
(( $+functions[_streamd__timesheet_commands] )) ||
_streamd__timesheet_commands() {
    local commands; commands=()
    _describe -t commands 'streamd timesheet commands' commands "$@"
}
(( $+functions[_streamd__todo_commands] )) ||
_streamd__todo_commands() {
    local commands; commands=(
'edit:Edit a task by its number' \
'done:Mark a task as done' \
'help:Print this message or the help of the given subcommand(s)' \
    )
    _describe -t commands 'streamd todo commands' commands "$@"
}
(( $+functions[_streamd__todo__done_commands] )) ||
_streamd__todo__done_commands() {
    local commands; commands=()
    _describe -t commands 'streamd todo done commands' commands "$@"
}
(( $+functions[_streamd__todo__edit_commands] )) ||
_streamd__todo__edit_commands() {
    local commands; commands=()
    _describe -t commands 'streamd todo edit commands' commands "$@"
}
(( $+functions[_streamd__todo__help_commands] )) ||
_streamd__todo__help_commands() {
    local commands; commands=(
'edit:Edit a task by its number' \
'done:Mark a task as done' \
'help:Print this message or the help of the given subcommand(s)' \
    )
    _describe -t commands 'streamd todo help commands' commands "$@"
}
(( $+functions[_streamd__todo__help__done_commands] )) ||
_streamd__todo__help__done_commands() {
    local commands; commands=()
    _describe -t commands 'streamd todo help done commands' commands "$@"
}
(( $+functions[_streamd__todo__help__edit_commands] )) ||
_streamd__todo__help__edit_commands() {
    local commands; commands=()
    _describe -t commands 'streamd todo help edit commands' commands "$@"
}
(( $+functions[_streamd__todo__help__help_commands] )) ||
_streamd__todo__help__help_commands() {
    local commands; commands=()
    _describe -t commands 'streamd todo help help commands' commands "$@"
}

if [ "$funcstack[1]" = "_streamd" ]; then
    _streamd "$@"
else
    compdef _streamd streamd
fi
