Skip to content

Latest commit

 

History

History
178 lines (161 loc) · 6.24 KB

README.md

File metadata and controls

178 lines (161 loc) · 6.24 KB

docopt.sh

⚠️🚧 Under development 🚧⚠️

TODO LIST

docopt text parser

OPTIONS

Usage:
    program defintion

Options:
    <this area>
  • short option
    • -o
    • -o ARG
    • -o <arg>
    • -o ARG...
    • -o <arg>...
  • long option
    • --option
    • --option ARG
    • --option=ARG
    • --option <arg>
    • --option=<arg>
    • --option ARG...
    • --option <arg>...
    • --option=ARG...
    • --option=<arg>...
  • option with default value
    • [default: value]
    • Option description. [default: value]
  • comma between short and long options
    • -o, --option
    • -o ARG, --option
    • -o <arg>, --option
    • -o ARG..., --option
    • -o <arg>..., --option
  • not necessary to define ARG / <arg> for both short and long option
    • -o ARG --option
    • -o --option ARG
    • -o ARG... --option
    • -o --option ARG...

PROGRAMS

Usage:
    <this area>

Options:
    options definition
  • short option
    • -o
    • -o ARG
    • -o <arg>
    • -o WRONG_ARG throw error if there is mismatch in naming of arguments declared in options area.
    • -o without ARG but it is declared in options that it takes an argument.
    • -v... continous option.
    • -o ARG...
    • -o <arg>...
    • -v... throw error if it declared in options that it takes an argument.
    • -abc consecutive short options with a single dash .
  • long option
    • --option
    • --option ARG
    • --option=ARG
    • --option <arg>
    • --option=<arg>
    • --option without ARG it is declared in options that it takes an argument.
    • --option WRONG_ARG throw error if there is mismatch in naming of arguments declared in options area.
    • --verbose... continous option
    • --option ARG...
    • --option=ARG...
    • --option <arg>...
    • --option=<arg>...
    • --verbose... throw error if it declared in options that it takes an argument.
  • optional options
    • [-o]
    • [-o ARG]
    • [-o ARG...]
    • [-o <arg>]
    • [--option]
    • [--option ARG]
    • [--option=ARG]
    • [--option <arg>]
    • [--option=<arg>]
    • [-o <arg>...]
    • [--option ARG...]
    • [--option=ARG...]
    • [--option <arg>...]
    • [--option=<arg>...]
    • [options] special "all options" allowed in no particular order.
  • commands
    • command
    • command...
    • [command] optional command.
    • [command...] optional continous command.
  • positional argument
    • ARG
    • ARG... continous argument resolves to multiple values.
    • ARG ARG... singular and plural definition resolves to multiple values.
  • multiple optionals
    • [--input --output] multiple long options inside a single pair of brackets.
    • [-i -o] multiple short options inside a single pair of brackets.
    • [-io] consecutiave short options.
    • [FILE1 FILE2] positional arguments.
  • grouping
    • --option1 | --option2 | --option3 ...
    • command1 | command2 | command3 ...
    • (--input --ouput | --in --out) multiple required pairs

ARGS BUILDING

declare -A ARGS=(
    ...this area
)
_docopt ()(...)
  • short option
    • -o short option without long counterpart resolves to short name with - prefix.
    • ✓ Defaults to false when no argument is declared.
    • ✓ Defatuls to empty -o= when argument is declared without a default.
    • [-i FILE] [default: -] Defaults declared default value.
  • long option
    • --option long option resolves to name with -- prefix.
    • ✓ Defaults to false.
    • ✓ Defatuls to empty --option= when argument is declared without a default.
    • [--input FILE] [default: -] Defaults to declared default value.
  • short and long
    • -o --option resolves to long name with -- prefix.
  • command
    • command Defaults to false on singular value.
    • command... Defaults to 0 on continous values.
  • positional
    • ARG Defaults to empty ARG= on singular value.
    • ARG... Defaults to empty ARG= on continous values.

ARGV PARSER

$ program <this area>
  • ✓ empty program
  • option
    • --option match required without argument.
    • --option=ARG match required with argument.
    • -- match provided optional wihout argument.
    • ✓ match provided optional with argument.
    • ✓ match non-provided optional wihout argument.
    • ✓ match non-provided optional with argument.
    • ✗ error on non-exiting option.
  • command
    • ✓ match required singular.
    • ✓ match required continous.
    • ✓ match provided optional singular.
    • ✓ match provided optional continous.
    • ✓ match non-provided optional singular.
    • ✓ match non-provided optional continous.
    • ✗ error on non-exiting command.
  • positional
    • ARG match required singular.
    • ARG... match required continous.
    • [ARG] match provided optional singular.
    • [ARG...] match provided optional continous.
    • [ARG] match non-provided optional singular.
    • [ARG...] match non-provided optional continous.
    • ✗ error when required not met.