#compdef undertime

_timezones() {
    python3 -c "import pytz; print(' '.join(pytz.all_timezones))"
}

_undertime() {
    _arguments \
        {-t,--timezones}"[time zones to show]:*:timezones:( $(_timezones) )" \
        '--config+[yaml config file]:filename:_files -g "*.(yaml|yml)"' \
        {-s,--start}+'[start of the working day]:hour:' \
        {-e,--end}'[end of the working day]:hour:' \
        "--no-colors[don\'t don't show colors]" \
        '--colors[show colors]' \
        '--default-zone[show current time zone first]' \
        "--no-default-zone[don't show current time zone first]" \
        '--unique[deduplicate time zone offsets]' \
        "--no-unique[don't show current time zone first]" \
        '--overlap[show zones overlap]' \
        "--no-overlap[don't show zones overlap]" \
        '--overlap-min[minimum overlap between zones]:number:' \
        '--truncate[short column headers]' \
        "--no-truncate[don't shorten column headers]" \
        '--table[show the table]' \
        "--no-table[hide the table]" \
        '--debug[enable debugging messages]' \
        {-f,--format}+'[format string for the tabulate package to format the main table]:string:(fancy_grid github grid html jira latex latex_booktabs latex_raw mediawiki moinmoin orgtbl pipe plain presto pretty psql rst simple textile tsv youtrack fancy_grid_nogap)' \
        {-v,--verbose}'[enable verbose messages]' \
        {-l,--list-zones}'[show valid time zones and exit]' \
        {-V,--version}'[print version number and exit]' \
        {-h,--help}'[show summary of options and defaults]' \
        '--selftest[run test suite]'
}

_undertime "$@"
