#compdef sharkmer

autoload -U is-at-least

_sharkmer() {
    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[@]}" : \
'--ena=[Stream reads directly from ENA by accession (e.g. SRR5324768)]:ENA:_default' \
'-s+[Sample name (output file prefix; required unless --ena derives it)]:SAMPLE:_default' \
'--sample=[Sample name (output file prefix; required unless --ena derives it)]:SAMPLE:_default' \
'-o+[Output directory]:OUTDIR:_files' \
'--outdir=[Output directory]:OUTDIR:_files' \
'*--pcr-panel=[Use a preconfigured primer panel (repeatable)]:PCR_PANEL:_default' \
'*--pcr-panel-file=[Load a primer panel from a YAML file or URL (repeatable)]:PCR_PANEL_FILE:_default' \
'*--pcr-primers=[Specify a primer pair inline (repeatable, see --help-pcr)]:PCR_PRIMERS:_default' \
'--export-panel=[Export a built-in panel as YAML to stdout and exit]:EXPORT_PANEL:_default' \
'-k+[Kmer length]:K:_default' \
'--chunks=[Number of incremental chunks (0 = skip histograms)]:CHUNKS:_default' \
'--histo-max=[Maximum histogram count value]:HISTO_MAX:_default' \
'-t+[Number of threads]:THREADS:_default' \
'--threads=[Number of threads]:THREADS:_default' \
'-m+[Maximum number of reads to process (default\: all)]:MAX_READS:_default' \
'--max-reads=[Maximum number of reads to process (default\: all)]:MAX_READS:_default' \
'--min-kmer-count=[Minimum kmer count for sPCR (filters low-count kmers before PCR)]:MIN_KMER_COUNT:_default' \
'--validate-every=[Validate FASTQ format every N records (0 = first record only)]:VALIDATE_EVERY:_default' \
'--color=[Color output]:COLOR:(auto always never)' \
'--completions=[Print shell tab-completion script and exit]:SHELL:(bash elvish fish powershell zsh)' \
'--list-panels[List available primer panels and exit]' \
'--help-pcr[Show detailed help for --pcr-primers format]' \
'*-v[Increase verbosity (-v info, -vv debug, -vvv trace)]' \
'*--verbose[Increase verbosity (-v info, -vv debug, -vvv trace)]' \
'-q[Suppress all output except errors]' \
'--quiet[Suppress all output except errors]' \
'--cite[Print citation information and exit]' \
'--validate-panels[Validate primer panels/primers and exit]' \
'--dry-run[Validate inputs and print what would happen, then exit]' \
'-h[Print help]' \
'--help[Print help]' \
'-V[Print version]' \
'--version[Print version]' \
'*::input -- FASTQ input files (.fastq or .fastq.gz). Reads from stdin if omitted:_files' \
&& ret=0
}

(( $+functions[_sharkmer_commands] )) ||
_sharkmer_commands() {
    local commands; commands=()
    _describe -t commands 'sharkmer commands' commands "$@"
}

if [ "$funcstack[1]" = "_sharkmer" ]; then
    _sharkmer "$@"
else
    compdef _sharkmer sharkmer
fi
