[Docpie]

Fork me on GitHub

Known Issue


Repeatable elements greedy matching

docpie support cp style command line:

Usage: cp <source_file>... <target_directory>

Here is the rules:

  1. The repeatable element can only be Argument:

    • ✔:(<arg1>)... <arg2> <arg3>
    • ✔:[<arg1>]... <arg2> <arg3>
    • ✔:(<arg1> <arg2>)... <arg3>
    • ✔:(<arg1> [<arg2> <arg3>])... <arg4> (Can be nested)
    • ✕:-a... -a (only support Argument)
    • ✕:cmd... cmd (only support Argument)
    • ✕:(<arg> cmd)... <arg2> (only support Argument)
  2. the following element can be Argument-s or Command-s (or both), can be grouped by () or []:

    • ✔:<arg>... cmd
    • ✔:<arg1>... (<arg2> <arg3>)
  3. When repeatable elements sharing the values, them will hold at least one value, which means:

    For [<arg1>]... <arg2> <arg3>

    • ✕:Can not match a1 a2, because <arg1> will hold the a1, which will cause <arg3> unmatched.
    • ✔:can match a1 a2 a3
  4. The following optional elements will not be matched.

    For example, <arg1>... [<arg2>] <arg3> matching a1 a2 a3 will get:

    {'<arg1>': ['a1', 'a2'], '<arg2>': None, '<arg3>': 'a3'}


If you like this project, you can buy me a beer to help me make it better! | Flattr this

侧栏导航