[Docpie]

Fork me on GitHub

Why docpie?


In contrast with argparse, docpie can

  1. reduce the code, in all the following update you only need to modify your help message
  2. greatly reduce the learning curve, what you see is what you get

In contrast with docopt, docpie can

  1. Some BUGs in docopt do not exist in docpie: #71 >>, #282 >>, #130 >>, #275 >>, #209 >>
  2. Support cp style command line

    '''
    Usage: mycopy.py <source_file>;... <target_directory>;
    '''
    
    from docpie import docpie
    from docopt import docopt
    
    print('---- docopt ----')
    try:
       print(docopt(__doc__))
    except BaseException as e:
       print(e)
    
    print('---- docpie ----')
    try:
       print(docpie(__doc__))
    except BaseException as e:
       print(e)
    

    output:

    $ python mycopy.py ./docpie/*.py ./docpie/test/*.py ~/my_project
    ---- docopt ----
    Usage: mycopy.py <source_file>... <target_directory>
    ---- docpie ----
    {'--': False,
     '<source_file>': ['./docpie/setup.py', './docpie/test/*.py'],
     '<target_directory>': '/Users/tyler/my_project'}
    

    try it >>

  3. automatically deal -- command, you don't need to write it again in your help message.

    """Usage: prog <hello>"""
    from docpie import docpie
    print(docpie(__doc__))
    

    try it >>

    When inputting -- --world it will return {'--': True, '<hello>': '--world'}

  4. specific program's name

    """
    Usage:
        myscript.py config
        $ python myscript.py make
        $ sudo python myscript.py make install
    """
    from docpie import docpie
    print(docpie(__doc__), name='myscript.py')

    try it >>

  5. pickle & JSONlize Docpie instance

  6. define and customize the automatically handled option-s

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

侧栏导航