#compdef sqlite sqlite3 _sqlite () { local opt display_opt excludeopts local -a _opts _output_modes _opts=( '-init[startup file]:file name to process:_files' '-echo[echo commands]' '(-noheader)-header[turn headers on]' '(-header)-noheader[turn headers off]' ) # output modes are mutually exclusive to each other _output_modes=( column HTML line list ) excludeopts="-${^_output_modes:l}" for display_opt in $_output_modes ; do opt=$display_opt:l # finagle the description to match the way SQLite's help formats them [[ $opt = $display_opt ]] && display_opt="'$display_opt'" _opts+=( "($excludeopts)-${opt}[set output mode to $display_opt]" ) done _opts+=( '-separator[set output field separator]:string to separate output fields:' '-nullvalue[set null value string]:string for NULL values:' '(- : *)-version[show SQLite version]' '(- : *)-help[show help]' "1:database file:_files -g '(#i)*.(db|$service)(-.)'" '*:SQL to run' ) _arguments -s $_opts }