#compdef numfmt autoload -U is-at-least _numfmt() { 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[@]}" : \ '-d+[use X instead of whitespace for field delimiter]:X:_default' \ '--delimiter=[use X instead of whitespace for field delimiter]:X:_default' \ '--field=[replace the numbers in these input fields; see FIELDS below]:FIELDS:_default' \ '--format=[use printf style floating-point FORMAT; see FORMAT below for details]:FORMAT:_default' \ '--from=[auto-scale input numbers to UNITs; see UNIT below]:UNIT:_default' \ '--from-unit=[specify the input unit size]:N:_default' \ '--to=[auto-scale output numbers to UNITs; see UNIT below]:UNIT:_default' \ '--to-unit=[the output unit size]:N:_default' \ '--padding=[pad the output to N characters; positive N will right-align; negative N will left-align; padding is ignored if the output is wider than N; the default is to automatically pad if a whitespace is found]:N:_default' \ '--header=[print (without converting) the first N header lines; N defaults to 1 if not specified]::N:_default' \ '--round=[use METHOD for rounding when scaling]:METHOD:(up down from-zero towards-zero nearest)' \ '--suffix=[print SUFFIX after each formatted number, and accept inputs optionally ending with SUFFIX]:SUFFIX:_default' \ '--unit-separator=[use STRING to separate the number from any unit when printing; by default, no separator is used]:STRING:_default' \ '--invalid=[set the failure mode for invalid input]:INVALID:(abort fail warn ignore)' \ '--debug[print warnings about invalid input]' \ '--grouping[use locale-defined grouping of digits, for example 1,000,000 (which means it has no effect in the C/POSIX locale)]' \ '-z[line delimiter is NUL, not newline]' \ '--zero-terminated[line delimiter is NUL, not newline]' \ '-h[Print help]' \ '--help[Print help]' \ '-V[Print version]' \ '--version[Print version]' \ '::NUMBER:_default' \ && ret=0 } (( $+functions[_numfmt_commands] )) || _numfmt_commands() { local commands; commands=() _describe -t commands 'numfmt commands' commands "$@" } if [ "$funcstack[1]" = "_numfmt" ]; then _numfmt "$@" else compdef _numfmt numfmt fi