#compdef asciinema

autoload -U is-at-least

_asciinema() {
    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[@]}" : \
'-q[Quiet mode - suppress diagnostic messages]' \
'--quiet[Quiet mode - suppress diagnostic messages]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
'-V[Print version]' \
'--version[Print version]' \
":: :_asciinema_commands" \
"*::: :->asciinema" \
&& ret=0
    case $state in
    (asciinema)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:asciinema-command-$line[1]:"
        case $line[1] in
            (record)
_arguments "${_arguments_options[@]}" : \
'-f+[Output file format \[default\: asciicast-v3\]]:FORMAT:((asciicast-v3\:"Full-featured session format, with timing and metadata (current generation) - https\://docs.asciinema.org/manual/asciicast/v3/"
asciicast-v2\:"Full-featured session format, with timing and metadata (previous generation) - https\://docs.asciinema.org/manual/asciicast/v2/"
raw\:"Raw terminal output, including control sequences, without timing and metadata"
txt\:"Plain text without colors or control sequences, human-readable"))' \
'--output-format=[Output file format \[default\: asciicast-v3\]]:FORMAT:((asciicast-v3\:"Full-featured session format, with timing and metadata (current generation) - https\://docs.asciinema.org/manual/asciicast/v3/"
asciicast-v2\:"Full-featured session format, with timing and metadata (previous generation) - https\://docs.asciinema.org/manual/asciicast/v2/"
raw\:"Raw terminal output, including control sequences, without timing and metadata"
txt\:"Plain text without colors or control sequences, human-readable"))' \
'-c+[Command to start in the session \[default\: \$SHELL\]]:COMMAND:_default' \
'--command=[Command to start in the session \[default\: \$SHELL\]]:COMMAND:_default' \
'--capture-env=[Comma-separated list of environment variables to capture \[default\: SHELL\]]:VARS:_default' \
'-t+[Title of the recording]:TITLE:_default' \
'--title=[Title of the recording]:TITLE:_default' \
'-i+[Limit idle time to a given number of seconds]:SECS:_default' \
'--idle-time-limit=[Limit idle time to a given number of seconds]:SECS:_default' \
'--window-size=[Override session'\''s terminal window size]:COLSxROWS:_default' \
'--log-file=[Log file path]:PATH:_files' \
'--cols=[]:COLS:_default' \
'--rows=[]:ROWS:_default' \
'-I[Enable input (keyboard) capture]' \
'--capture-input[Enable input (keyboard) capture]' \
'-a[Append to an existing recording file]' \
'--append[Append to an existing recording file]' \
'(-a --append)--overwrite[Overwrite the output file if it already exists]' \
'--headless[Headless mode - don'\''t use the terminal for I/O]' \
'--return[Return the session'\''s exit status]' \
'--raw[]' \
'-q[Quiet mode - suppress diagnostic messages]' \
'--quiet[Quiet mode - suppress diagnostic messages]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
':file -- Output file path:_default' \
&& ret=0
;;
(rec)
_arguments "${_arguments_options[@]}" : \
'-f+[Output file format \[default\: asciicast-v3\]]:FORMAT:((asciicast-v3\:"Full-featured session format, with timing and metadata (current generation) - https\://docs.asciinema.org/manual/asciicast/v3/"
asciicast-v2\:"Full-featured session format, with timing and metadata (previous generation) - https\://docs.asciinema.org/manual/asciicast/v2/"
raw\:"Raw terminal output, including control sequences, without timing and metadata"
txt\:"Plain text without colors or control sequences, human-readable"))' \
'--output-format=[Output file format \[default\: asciicast-v3\]]:FORMAT:((asciicast-v3\:"Full-featured session format, with timing and metadata (current generation) - https\://docs.asciinema.org/manual/asciicast/v3/"
asciicast-v2\:"Full-featured session format, with timing and metadata (previous generation) - https\://docs.asciinema.org/manual/asciicast/v2/"
raw\:"Raw terminal output, including control sequences, without timing and metadata"
txt\:"Plain text without colors or control sequences, human-readable"))' \
'-c+[Command to start in the session \[default\: \$SHELL\]]:COMMAND:_default' \
'--command=[Command to start in the session \[default\: \$SHELL\]]:COMMAND:_default' \
'--capture-env=[Comma-separated list of environment variables to capture \[default\: SHELL\]]:VARS:_default' \
'-t+[Title of the recording]:TITLE:_default' \
'--title=[Title of the recording]:TITLE:_default' \
'-i+[Limit idle time to a given number of seconds]:SECS:_default' \
'--idle-time-limit=[Limit idle time to a given number of seconds]:SECS:_default' \
'--window-size=[Override session'\''s terminal window size]:COLSxROWS:_default' \
'--log-file=[Log file path]:PATH:_files' \
'--cols=[]:COLS:_default' \
'--rows=[]:ROWS:_default' \
'-I[Enable input (keyboard) capture]' \
'--capture-input[Enable input (keyboard) capture]' \
'-a[Append to an existing recording file]' \
'--append[Append to an existing recording file]' \
'(-a --append)--overwrite[Overwrite the output file if it already exists]' \
'--headless[Headless mode - don'\''t use the terminal for I/O]' \
'--return[Return the session'\''s exit status]' \
'--raw[]' \
'-q[Quiet mode - suppress diagnostic messages]' \
'--quiet[Quiet mode - suppress diagnostic messages]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
':file -- Output file path:_default' \
&& ret=0
;;
(stream)
_arguments "${_arguments_options[@]}" : \
'-l+[Stream via the local HTTP server]' \
'--local=[Stream via the local HTTP server]' \
'-r+[Stream via remote asciinema server]' \
'--remote=[Stream via remote asciinema server]' \
'-c+[Command to start in the session \[default\: \$SHELL\]]:COMMAND:_default' \
'--command=[Command to start in the session \[default\: \$SHELL\]]:COMMAND:_default' \
'--capture-env=[Comma-separated list of environment variables to capture \[default\: SHELL\]]:VARS:_default' \
'-t+[Title of the session]:TITLE:_default' \
'--title=[Title of the session]:TITLE:_default' \
'--window-size=[Override session'\''s terminal window size]:COLSxROWS:_default' \
'--log-file=[Log file path]:PATH:_files' \
'--server-url=[asciinema server URL]:URL:_default' \
'-I[Enable input (keyboard) capture]' \
'--capture-input[Enable input (keyboard) capture]' \
'--headless[Headless mode - don'\''t use the terminal for I/O]' \
'--return[Return the session'\''s exit status]' \
'-q[Quiet mode - suppress diagnostic messages]' \
'--quiet[Quiet mode - suppress diagnostic messages]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
&& ret=0
;;
(session)
_arguments "${_arguments_options[@]}" : \
'-o+[Save the session to a file]:PATH:_default' \
'--output-file=[Save the session to a file]:PATH:_default' \
'-f+[Output file format \[default\: asciicast-v3\]]:FORMAT:((asciicast-v3\:"Full-featured session format, with timing and metadata (current generation) - https\://docs.asciinema.org/manual/asciicast/v3/"
asciicast-v2\:"Full-featured session format, with timing and metadata (previous generation) - https\://docs.asciinema.org/manual/asciicast/v2/"
raw\:"Raw terminal output, including control sequences, without timing and metadata"
txt\:"Plain text without colors or control sequences, human-readable"))' \
'--output-format=[Output file format \[default\: asciicast-v3\]]:FORMAT:((asciicast-v3\:"Full-featured session format, with timing and metadata (current generation) - https\://docs.asciinema.org/manual/asciicast/v3/"
asciicast-v2\:"Full-featured session format, with timing and metadata (previous generation) - https\://docs.asciinema.org/manual/asciicast/v2/"
raw\:"Raw terminal output, including control sequences, without timing and metadata"
txt\:"Plain text without colors or control sequences, human-readable"))' \
'-l+[Stream via the local HTTP server]' \
'--stream-local=[Stream via the local HTTP server]' \
'-r+[Stream via remote asciinema server]' \
'--stream-remote=[Stream via remote asciinema server]' \
'-c+[Command to start in the session \[default\: \$SHELL\]]:COMMAND:_default' \
'--command=[Command to start in the session \[default\: \$SHELL\]]:COMMAND:_default' \
'--capture-env=[Comma-separated list of environment variables to capture \[default\: SHELL\]]:VARS:_default' \
'-t+[Title of the session]:TITLE:_default' \
'--title=[Title of the session]:TITLE:_default' \
'-i+[Limit idle time to a given number of seconds]:SECS:_default' \
'--idle-time-limit=[Limit idle time to a given number of seconds]:SECS:_default' \
'--window-size=[Override session'\''s terminal window size]:COLSxROWS:_default' \
'--log-file=[Log file path]:PATH:_files' \
'--server-url=[asciinema server URL]:URL:_default' \
'-I[Enable input (keyboard) capture]' \
'--capture-input[Enable input (keyboard) capture]' \
'-a[Append to an existing recording file]' \
'--append[Append to an existing recording file]' \
'(-a --append)--overwrite[Overwrite the output file if it already exists]' \
'--headless[Headless mode - don'\''t use the terminal for I/O]' \
'--return[Return the session'\''s exit status]' \
'-q[Quiet mode - suppress diagnostic messages]' \
'--quiet[Quiet mode - suppress diagnostic messages]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
'*::env:_default' \
&& ret=0
;;
(play)
_arguments "${_arguments_options[@]}" : \
'-s+[Set playback speed]:SPEED:_default' \
'--speed=[Set playback speed]:SPEED:_default' \
'-i+[Limit idle time to a given number of seconds]:SECS:_default' \
'--idle-time-limit=[Limit idle time to a given number of seconds]:SECS:_default' \
'-l[Loop playback continuously]' \
'--loop[Loop playback continuously]' \
'-m[Automatically pause on markers]' \
'--pause-on-markers[Automatically pause on markers]' \
'-r[Auto-resize terminal to match original size]' \
'--resize[Auto-resize terminal to match original size]' \
'-q[Quiet mode - suppress diagnostic messages]' \
'--quiet[Quiet mode - suppress diagnostic messages]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
':file -- The path to an asciicast file or HTTP(S) URL to play back. HTTP(S) URLs allow playing recordings directly from the web without need for manual downloading. Supported formats include asciicast v1, v2, and v3:_default' \
&& ret=0
;;
(upload)
_arguments "${_arguments_options[@]}" : \
'--server-url=[asciinema server URL]:URL:_default' \
'-q[Quiet mode - suppress diagnostic messages]' \
'--quiet[Quiet mode - suppress diagnostic messages]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
':file -- The path to the asciicast recording file to upload, in a supported asciicast format (v1, v2, or v3):_default' \
&& ret=0
;;
(auth)
_arguments "${_arguments_options[@]}" : \
'--server-url=[asciinema server URL]:URL:_default' \
'-q[Quiet mode - suppress diagnostic messages]' \
'--quiet[Quiet mode - suppress diagnostic messages]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
&& ret=0
;;
(cat)
_arguments "${_arguments_options[@]}" : \
'-q[Quiet mode - suppress diagnostic messages]' \
'--quiet[Quiet mode - suppress diagnostic messages]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
'*::file -- Recording files to concatenate:_default' \
&& ret=0
;;
(convert)
_arguments "${_arguments_options[@]}" : \
'-f+[Output file format \[default\: asciicast-v3\]]:FORMAT:((asciicast-v3\:"Full-featured session format, with timing and metadata (current generation) - https\://docs.asciinema.org/manual/asciicast/v3/"
asciicast-v2\:"Full-featured session format, with timing and metadata (previous generation) - https\://docs.asciinema.org/manual/asciicast/v2/"
raw\:"Raw terminal output, including control sequences, without timing and metadata"
txt\:"Plain text without colors or control sequences, human-readable"))' \
'--output-format=[Output file format \[default\: asciicast-v3\]]:FORMAT:((asciicast-v3\:"Full-featured session format, with timing and metadata (current generation) - https\://docs.asciinema.org/manual/asciicast/v3/"
asciicast-v2\:"Full-featured session format, with timing and metadata (previous generation) - https\://docs.asciinema.org/manual/asciicast/v2/"
raw\:"Raw terminal output, including control sequences, without timing and metadata"
txt\:"Plain text without colors or control sequences, human-readable"))' \
'--overwrite[Overwrite the output file if it already exists]' \
'-q[Quiet mode - suppress diagnostic messages]' \
'--quiet[Quiet mode - suppress diagnostic messages]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
':input -- The source recording to convert. Can be a local file path, HTTP(S) URL for remote files, or '\''-'\'' to read from standard input. Remote URLs allow converting recordings directly from the web without need for manual downloading. Supported input formats include asciicast v1, v2 and v3:_default' \
':output -- The output path for the converted recording. Can be a file path or '\''-'\'' to write to standard output:_default' \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" : \
":: :_asciinema__help_commands" \
"*::: :->help" \
&& ret=0

    case $state in
    (help)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:asciinema-help-command-$line[1]:"
        case $line[1] in
            (record)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(stream)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(session)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(play)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(upload)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(auth)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(cat)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(convert)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
        esac
    ;;
esac
;;
        esac
    ;;
esac
}

(( $+functions[_asciinema_commands] )) ||
_asciinema_commands() {
    local commands; commands=(
'record:Record a terminal session' \
'rec:Record a terminal session' \
'stream:Stream a terminal session' \
'session:Record and stream a terminal session' \
'play:Play back a terminal session' \
'upload:Upload a recording to an asciinema server' \
'auth:Authenticate this CLI with an asciinema server account' \
'cat:Concatenate multiple recordings' \
'convert:Convert a recording to another format' \
'help:Print this message or the help of the given subcommand(s)' \
    )
    _describe -t commands 'asciinema commands' commands "$@"
}
(( $+functions[_asciinema__auth_commands] )) ||
_asciinema__auth_commands() {
    local commands; commands=()
    _describe -t commands 'asciinema auth commands' commands "$@"
}
(( $+functions[_asciinema__cat_commands] )) ||
_asciinema__cat_commands() {
    local commands; commands=()
    _describe -t commands 'asciinema cat commands' commands "$@"
}
(( $+functions[_asciinema__convert_commands] )) ||
_asciinema__convert_commands() {
    local commands; commands=()
    _describe -t commands 'asciinema convert commands' commands "$@"
}
(( $+functions[_asciinema__help_commands] )) ||
_asciinema__help_commands() {
    local commands; commands=(
'record:Record a terminal session' \
'stream:Stream a terminal session' \
'session:Record and stream a terminal session' \
'play:Play back a terminal session' \
'upload:Upload a recording to an asciinema server' \
'auth:Authenticate this CLI with an asciinema server account' \
'cat:Concatenate multiple recordings' \
'convert:Convert a recording to another format' \
'help:Print this message or the help of the given subcommand(s)' \
    )
    _describe -t commands 'asciinema help commands' commands "$@"
}
(( $+functions[_asciinema__help__auth_commands] )) ||
_asciinema__help__auth_commands() {
    local commands; commands=()
    _describe -t commands 'asciinema help auth commands' commands "$@"
}
(( $+functions[_asciinema__help__cat_commands] )) ||
_asciinema__help__cat_commands() {
    local commands; commands=()
    _describe -t commands 'asciinema help cat commands' commands "$@"
}
(( $+functions[_asciinema__help__convert_commands] )) ||
_asciinema__help__convert_commands() {
    local commands; commands=()
    _describe -t commands 'asciinema help convert commands' commands "$@"
}
(( $+functions[_asciinema__help__help_commands] )) ||
_asciinema__help__help_commands() {
    local commands; commands=()
    _describe -t commands 'asciinema help help commands' commands "$@"
}
(( $+functions[_asciinema__help__play_commands] )) ||
_asciinema__help__play_commands() {
    local commands; commands=()
    _describe -t commands 'asciinema help play commands' commands "$@"
}
(( $+functions[_asciinema__help__record_commands] )) ||
_asciinema__help__record_commands() {
    local commands; commands=()
    _describe -t commands 'asciinema help record commands' commands "$@"
}
(( $+functions[_asciinema__help__session_commands] )) ||
_asciinema__help__session_commands() {
    local commands; commands=()
    _describe -t commands 'asciinema help session commands' commands "$@"
}
(( $+functions[_asciinema__help__stream_commands] )) ||
_asciinema__help__stream_commands() {
    local commands; commands=()
    _describe -t commands 'asciinema help stream commands' commands "$@"
}
(( $+functions[_asciinema__help__upload_commands] )) ||
_asciinema__help__upload_commands() {
    local commands; commands=()
    _describe -t commands 'asciinema help upload commands' commands "$@"
}
(( $+functions[_asciinema__play_commands] )) ||
_asciinema__play_commands() {
    local commands; commands=()
    _describe -t commands 'asciinema play commands' commands "$@"
}
(( $+functions[_asciinema__record_commands] )) ||
_asciinema__record_commands() {
    local commands; commands=()
    _describe -t commands 'asciinema record commands' commands "$@"
}
(( $+functions[_asciinema__session_commands] )) ||
_asciinema__session_commands() {
    local commands; commands=()
    _describe -t commands 'asciinema session commands' commands "$@"
}
(( $+functions[_asciinema__stream_commands] )) ||
_asciinema__stream_commands() {
    local commands; commands=()
    _describe -t commands 'asciinema stream commands' commands "$@"
}
(( $+functions[_asciinema__upload_commands] )) ||
_asciinema__upload_commands() {
    local commands; commands=()
    _describe -t commands 'asciinema upload commands' commands "$@"
}

if [ "$funcstack[1]" = "_asciinema" ]; then
    _asciinema "$@"
else
    compdef _asciinema asciinema
fi
