#compdef erd

autoload -U is-at-least

_erd() {
    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[@]}" \
'-c+[Use configuration of named table rather than the top-level table in .erdtree.toml]:CONFIG: ' \
'--config=[Use configuration of named table rather than the top-level table in .erdtree.toml]:CONFIG: ' \
'-C+[Mode of coloring output]:COLOR:((none\:"Print plainly without ANSI escapes"
auto\:"Attempt to colorize output"
force\:"Turn on colorization always"))' \
'--color=[Mode of coloring output]:COLOR:((none\:"Print plainly without ANSI escapes"
auto\:"Attempt to colorize output"
force\:"Turn on colorization always"))' \
'-d+[Print physical or logical file size]:DISK_USAGE:((logical\:"How many bytes does a file contain"
physical\:"How many actual bytes on disk, taking into account blocks, sparse files, and compression"
line\:"How many total lines a file contains"
word\:"How many total words a file contains"
block\:"How many blocks are allocated to store the file"))' \
'--disk-usage=[Print physical or logical file size]:DISK_USAGE:((logical\:"How many bytes does a file contain"
physical\:"How many actual bytes on disk, taking into account blocks, sparse files, and compression"
line\:"How many total lines a file contains"
word\:"How many total words a file contains"
block\:"How many blocks are allocated to store the file"))' \
'--time=[Which kind of timestamp to use; modified by default]:TIME:((create\:"Time created (alias: ctime)"
access\:"Time last accessed (alias: atime)"
mod\:"Time last modified (alias: mtime)"))' \
'--time-format=[Which format to use for the timestamp; default by default]:TIME_FORMAT:((iso\:"Timestamp formatted following the iso8601, with slight differences and the time-zone omitted"
iso-strict\:"Timestamp formatted following the exact iso8601 specifications"
short\:"Timestamp only shows date without time in YYYY-MM-DD format"
default\:"Timestamp is shown in DD MMM HH:MM format"))' \
'-L+[Maximum depth to display]:NUM: ' \
'--level=[Maximum depth to display]:NUM: ' \
'-p+[Regular expression (or glob if '\''--glob'\'' or '\''--iglob'\'' is used) used to match files]:PATTERN: ' \
'--pattern=[Regular expression (or glob if '\''--glob'\'' or '\''--iglob'\'' is used) used to match files]:PATTERN: ' \
'-t+[Restrict regex or glob search to a particular file-type]:FILE_TYPE:((file\:"A regular file"
dir\:"A directory"
link\:"A symlink"))' \
'--file-type=[Restrict regex or glob search to a particular file-type]:FILE_TYPE:((file\:"A regular file"
dir\:"A directory"
link\:"A symlink"))' \
'-s+[How to sort entries]:SORT:((name\:"Sort entries by file name in lexicographical order"
rname\:"Sort entries by file name in reversed lexicographical order"
size\:"Sort entries by size smallest to largest, top to bottom"
rsize\:"Sort entries by size largest to smallest, bottom to top"
access\:"Sort entries by newer to older Accessing Date"
raccess\:"Sort entries by older to newer Accessing Date"
create\:"Sort entries by newer to older Creation Date"
rcreate\:"Sort entries by older to newer Creation Date"
mod\:"Sort entries by newer to older Alteration Date"
rmod\:"Sort entries by older to newer Alteration Date"))' \
'--sort=[How to sort entries]:SORT:((name\:"Sort entries by file name in lexicographical order"
rname\:"Sort entries by file name in reversed lexicographical order"
size\:"Sort entries by size smallest to largest, top to bottom"
rsize\:"Sort entries by size largest to smallest, bottom to top"
access\:"Sort entries by newer to older Accessing Date"
raccess\:"Sort entries by older to newer Accessing Date"
create\:"Sort entries by newer to older Creation Date"
rcreate\:"Sort entries by older to newer Creation Date"
mod\:"Sort entries by newer to older Alteration Date"
rmod\:"Sort entries by older to newer Alteration Date"))' \
'--dir-order=[Sort directories before or after all other file types]:DIR_ORDER:((none\:"Directories are ordered as if they were regular nodes"
first\:"Sort directories above files"
last\:"Sort directories below files"))' \
'-T+[Number of threads to use]:THREADS: ' \
'--threads=[Number of threads to use]:THREADS: ' \
'-u+[Report disk usage in binary or SI units]:UNIT:((bin\:"Displays disk usage using binary prefixes"
si\:"Displays disk usage using SI prefixes"))' \
'--unit=[Report disk usage in binary or SI units]:UNIT:((bin\:"Displays disk usage using binary prefixes"
si\:"Displays disk usage using SI prefixes"))' \
'-y+[Which kind of layout to use when rendering the output]:LAYOUT:((regular\:"Outputs the tree with the root node at the bottom of the output"
inverted\:"Outputs the tree with the root node at the top of the output"
flat\:"Outputs a flat layout using paths rather than an ASCII tree"
iflat\:"Outputs an inverted flat layout with the root at the top of the output"))' \
'--layout=[Which kind of layout to use when rendering the output]:LAYOUT:((regular\:"Outputs the tree with the root node at the bottom of the output"
inverted\:"Outputs the tree with the root node at the top of the output"
flat\:"Outputs a flat layout using paths rather than an ASCII tree"
iflat\:"Outputs an inverted flat layout with the root at the top of the output"))' \
'--completions=[Print completions for a given shell to stdout]:COMPLETIONS:(bash elvish fish powershell zsh)' \
'-f[Follow symlinks]' \
'--follow[Follow symlinks]' \
'-H[Print disk usage in human-readable format]' \
'--human[Print disk usage in human-readable format]' \
'-i[Do not respect .gitignore files]' \
'--no-ignore[Do not respect .gitignore files]' \
'-I[Display file icons]' \
'--icons[Display file icons]' \
'-l[Show extended metadata and attributes]' \
'--long[Show extended metadata and attributes]' \
'--group[Show file'\''s groups]' \
'--ino[Show each file'\''s ino]' \
'--nlink[Show the total number of hardlinks to the underlying inode]' \
'--octal[Show permissions in numeric octal format instead of symbolic]' \
'--glob[Enables glob based searching]' \
'--iglob[Enables case-insensitive glob based searching]' \
'-P[Remove empty directories from output]' \
'--prune[Remove empty directories from output]' \
'-x[Prevent traversal into directories that are on different filesystems]' \
'--one-file-system[Prevent traversal into directories that are on different filesystems]' \
'-.[Show hidden files]' \
'--hidden[Show hidden files]' \
'--no-git[Disable traversal of .git directory when traversing hidden files]' \
'--dirs-only[Only print directories]' \
'--no-config[Don'\''t read configuration file]' \
'--no-progress[Hides the progress indicator]' \
'--suppress-size[Omit disk usage from output]' \
'--truncate[Truncate output to fit terminal emulator window]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
'-V[Print version]' \
'--version[Print version]' \
'::dir -- Directory to traverse; defaults to current working directory:_files' \
&& ret=0
}

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

if [ "$funcstack[1]" = "_erd" ]; then
    _erd "$@"
else
    compdef _erd erd
fi
