#compdef svg2pdf

autoload -U is-at-least

_svg2pdf() {
    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[@]}" : \
'--dpi=[The number of SVG pixels per PDF points]:DPI: ' \
'--raster-scale=[How much raster images of rasterized effects should be scaled up]:RASTER_SCALE: ' \
'*-v[Sets the level of logging verbosity\: -v = warning & error, -vv = info, -vvv = debug, -vvvv = trace]' \
'*--verbosity[Sets the level of logging verbosity\: -v = warning & error, -vv = info, -vvv = debug, -vvvv = trace]' \
'-t[Whether text should be converted to paths before embedding it into the PDF]' \
'--text-to-paths[Whether text should be converted to paths before embedding it into the PDF]' \
'-h[Print help]' \
'--help[Print help]' \
'-V[Print version]' \
'--version[Print version]' \
'::input -- Path to read SVG file from:_files' \
'::output -- Path to write PDF file to:_files' \
":: :_svg2pdf_commands" \
"*::: :->svg2pdf-cli" \
&& ret=0
    case $state in
    (svg2pdf-cli)
        words=($line[3] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:svg2pdf-command-$line[3]:"
        case $line[3] in
            (fonts)
_arguments "${_arguments_options[@]}" : \
'--all[Also lists style variants of each font family]' \
'-h[Print help]' \
'--help[Print help]' \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" : \
":: :_svg2pdf__help_commands" \
"*::: :->help" \
&& ret=0

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

(( $+functions[_svg2pdf_commands] )) ||
_svg2pdf_commands() {
    local commands; commands=(
'fonts:Lists all discovered fonts in system' \
'help:Print this message or the help of the given subcommand(s)' \
    )
    _describe -t commands 'svg2pdf commands' commands "$@"
}
(( $+functions[_svg2pdf__fonts_commands] )) ||
_svg2pdf__fonts_commands() {
    local commands; commands=()
    _describe -t commands 'svg2pdf fonts commands' commands "$@"
}
(( $+functions[_svg2pdf__help_commands] )) ||
_svg2pdf__help_commands() {
    local commands; commands=(
'fonts:Lists all discovered fonts in system' \
'help:Print this message or the help of the given subcommand(s)' \
    )
    _describe -t commands 'svg2pdf help commands' commands "$@"
}
(( $+functions[_svg2pdf__help__fonts_commands] )) ||
_svg2pdf__help__fonts_commands() {
    local commands; commands=()
    _describe -t commands 'svg2pdf help fonts commands' commands "$@"
}
(( $+functions[_svg2pdf__help__help_commands] )) ||
_svg2pdf__help__help_commands() {
    local commands; commands=()
    _describe -t commands 'svg2pdf help help commands' commands "$@"
}

if [ "$funcstack[1]" = "_svg2pdf" ]; then
    _svg2pdf "$@"
else
    compdef _svg2pdf svg2pdf
fi
