#compdef qrab
autoload -U is-at-least
_qrab() {
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]' \
":: :_qrab_commands" \
"*::: :->qrab" \
&& ret=0
case $state in
(qrab)
words=($line[1] "${words[@]}")
(( CURRENT += 1 ))
curcontext="${curcontext%:*:*}:qrab-command-$line[1]:"
case $line[1] in
(check)
_arguments "${_arguments_options[@]}" : \
'-h[Print help]' \
'--help[Print help]' \
'-V[Print version]' \
'--version[Print version]' \
':input -- Input `.qrab` file:_files' \
&& ret=0
;;
(compile)
_arguments "${_arguments_options[@]}" : \
'-t+[Output backend]:TARGET:(latex typst svg quirk all)' \
'--target=[Output backend]:TARGET:(latex typst svg quirk all)' \
'-o+[Output file; requires a single backend]:OUTPUT:_files' \
'--output=[Output file; requires a single backend]:OUTPUT:_files' \
'-h[Print help]' \
'--help[Print help]' \
'-V[Print version]' \
'--version[Print version]' \
':input -- Input `.qrab` file:_files' \
&& ret=0
;;
(import-quirk)
_arguments "${_arguments_options[@]}" : \
'-o+[Output \`.qrab\` file; writes to stdout when omitted]:OUTPUT:_files' \
'--output=[Output \`.qrab\` file; writes to stdout when omitted]:OUTPUT:_files' \
'-h[Print help]' \
'--help[Print help]' \
'-V[Print version]' \
'--version[Print version]' \
':url -- Escaped or unescaped Quirk circuit URL:_default' \
&& ret=0
;;
(install-skill)
_arguments "${_arguments_options[@]}" : \
'-h[Print help]' \
'--help[Print help]' \
'-V[Print version]' \
'--version[Print version]' \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" : \
":: :_qrab__subcmd__help_commands" \
"*::: :->help" \
&& ret=0
case $state in
(help)
words=($line[1] "${words[@]}")
(( CURRENT += 1 ))
curcontext="${curcontext%:*:*}:qrab-help-command-$line[1]:"
case $line[1] in
(check)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(compile)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(import-quirk)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(install-skill)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
esac
;;
esac
;;
esac
;;
esac
}
(( $+functions[_qrab_commands] )) ||
_qrab_commands() {
local commands; commands=(
'check:Check a circuit without rendering it' \
'compile:Compile a circuit to LaTeX, Typst, SVG, Quirk, or all of them' \
'import-quirk:Convert a Quirk URL to qrab source' \
'install-skill:Install the qrab agent skill in the current project' \
'help:Print this message or the help of the given subcommand(s)' \
)
_describe -t commands 'qrab commands' commands "$@"
}
(( $+functions[_qrab__subcmd__check_commands] )) ||
_qrab__subcmd__check_commands() {
local commands; commands=()
_describe -t commands 'qrab check commands' commands "$@"
}
(( $+functions[_qrab__subcmd__compile_commands] )) ||
_qrab__subcmd__compile_commands() {
local commands; commands=()
_describe -t commands 'qrab compile commands' commands "$@"
}
(( $+functions[_qrab__subcmd__help_commands] )) ||
_qrab__subcmd__help_commands() {
local commands; commands=(
'check:Check a circuit without rendering it' \
'compile:Compile a circuit to LaTeX, Typst, SVG, Quirk, or all of them' \
'import-quirk:Convert a Quirk URL to qrab source' \
'install-skill:Install the qrab agent skill in the current project' \
'help:Print this message or the help of the given subcommand(s)' \
)
_describe -t commands 'qrab help commands' commands "$@"
}
(( $+functions[_qrab__subcmd__help__subcmd__check_commands] )) ||
_qrab__subcmd__help__subcmd__check_commands() {
local commands; commands=()
_describe -t commands 'qrab help check commands' commands "$@"
}
(( $+functions[_qrab__subcmd__help__subcmd__compile_commands] )) ||
_qrab__subcmd__help__subcmd__compile_commands() {
local commands; commands=()
_describe -t commands 'qrab help compile commands' commands "$@"
}
(( $+functions[_qrab__subcmd__help__subcmd__help_commands] )) ||
_qrab__subcmd__help__subcmd__help_commands() {
local commands; commands=()
_describe -t commands 'qrab help help commands' commands "$@"
}
(( $+functions[_qrab__subcmd__help__subcmd__import-quirk_commands] )) ||
_qrab__subcmd__help__subcmd__import-quirk_commands() {
local commands; commands=()
_describe -t commands 'qrab help import-quirk commands' commands "$@"
}
(( $+functions[_qrab__subcmd__help__subcmd__install-skill_commands] )) ||
_qrab__subcmd__help__subcmd__install-skill_commands() {
local commands; commands=()
_describe -t commands 'qrab help install-skill commands' commands "$@"
}
(( $+functions[_qrab__subcmd__import-quirk_commands] )) ||
_qrab__subcmd__import-quirk_commands() {
local commands; commands=()
_describe -t commands 'qrab import-quirk commands' commands "$@"
}
(( $+functions[_qrab__subcmd__install-skill_commands] )) ||
_qrab__subcmd__install-skill_commands() {
local commands; commands=()
_describe -t commands 'qrab install-skill commands' commands "$@"
}
if [ "$funcstack[1]" = "_qrab" ]; then
_qrab "$@"
else
compdef _qrab qrab
fi