Questions tagged [docopt]

Framework for creating command-line interfaces from docstrings.

docopt creates beautiful command-line interfaces:

The docopt Python module allows you to create powerful command line interfaces by simply passing a usage string like those printed by many posix tools. The command parser is automatically generated from the usage and the results of parsing provided arguments are returned as a dict.

Video introduction to docopt: PyCon UK 2012: Create beautiful command-line interfaces with Python.

The docopt module has also been ported to several other programming languages

147 questions
0
votes
0 answers

How to enter windows paths to run Python in Sublime Text 3 using Ctrl+B

I'm trying to run a python script using Sublime Text 3. I'm trying to just use Ctrl+b and type the parameters in the box that comes up, but I can't for the life of me figure out how to format the Windows file paths. I keep getting a…
PurpleVermont
  • 1,179
  • 4
  • 18
  • 46
0
votes
1 answer

Visual studio code reports docopt import error while there are no problems in bash terminal

Just installed extension ms-python.python Visual studio code reports in regard of my code in main.py Import "docopt" could not be resolved from source { "resource": "/home/XXXXXXXXX/main.py", "owner":…
0
votes
1 answer

docopt not showing usage string after converting python script to .exe

I'm working on a simple python command line tool which uses docopt. It works perfectly fine as it is. However upon being converted to .exe (using pyinstaller), the functions of the script still work but it no longer displays the usage string when no…
Jay
  • 110
  • 10
0
votes
0 answers

docopt usage not formatted correctly by sphinx

Consider the following doc-string for docopt: Usage: foo [options] foo [options] Options: -h, --help Show help. when formatting with Sphinx the options are formatted very nicely (bold options, with regular,…
Tom de Geus
  • 5,625
  • 2
  • 33
  • 77
0
votes
1 answer

docopt doesn't apply default value

I have the following usage string: usage = """Usage: counts_editing_precent_total_editing_to_csv.py out files ... [--percentageField=] [--numReadsField=] …
Eliran Turgeman
  • 1,526
  • 2
  • 16
  • 34
0
votes
0 answers

Testing a CLI made with docopt, with unittest

There is a part of the code in the file fastq_trimmer.py: if __name__ == '__main__': usage = ''' Fastq Trimmer CLI. Usage: fastq_trimmer.py trim ''' args = docopt(usage) if args['trim']: …
Eliran Turgeman
  • 1,526
  • 2
  • 16
  • 34
0
votes
1 answer

docopt not printing arguments

I am trying to learn how to use docopt. Below is my file docopt_test.py. Ideally I should get the passed arguments printed after I run this, but I am only getting output that is printing the usage comment. Can anyone kindly point me to what am I…
Inferno1892
  • 233
  • 1
  • 3
  • 11
0
votes
2 answers

Passing Python list in single quote

I have a piece of code like below which is used to send a list of IP addresses to an API call. body = {'cID': id, 'dbType': params['db-type'].upper(), 'cidrList': eval(params['--cidr-list'])} print(json.dumps(body)) conn.request("POST",…
0
votes
1 answer

Pass output of 'find' command to Python with docopt (issue with spaces)

Consider this simple Python command-line script: """foobar Description Usage: foobar [options] ... Arguments: List of files. Options: -h, --help Show help. --version Show version. """ import…
Tom de Geus
  • 5,625
  • 2
  • 33
  • 77
0
votes
2 answers

Docopt - Multiple values for an optional argument

I would like to parse an optional argument with multiple values with docopt. Below is the example usage. my_program.py --loc pcg acc # or anything that achieve similar result and after parsing, I expect that to have a python list like…
Darren Christopher
  • 3,893
  • 4
  • 20
  • 37
0
votes
0 answers

Weird issues with imports in python package

I'm building an installable python package, it's basically a CLI based on docopt and other herbs. The overall structure is as follows: README.md MANIFEST.in setup.py grok/ __init__.py module.py other_module.py main.py On my main.py I…
iferminm
  • 2,019
  • 19
  • 34
0
votes
2 answers

"docopt.DocoptLanguageError: --replicas must not have an argument" only with "replicas", not "replication"

Here is a working version of DocOpt (partially taken from naval fate): """ Instance Manager Usage: instance_manager cluster create ... [--google|--virtualbox] instance_manager cluster delete instance_manager…
Alexander Kleinhans
  • 5,950
  • 10
  • 55
  • 111
0
votes
1 answer

docopt parsing doesn't return the expected dictionary

I wanna do same cli tools and tried docopt but i struggled many times: here's my docstring: """ usage: wplan [--progress] [--forced] [--path DIR] [--verbosity VMODE] wplan -h options: --progress show progress bar …
jgsedi
  • 227
  • 4
  • 18
0
votes
2 answers

Dependent options in docopt

I was wondering if I could have dependent options in docopt. example: """ Description: Flash a system with the manufacturing software from the specifiedx folder. Usage: flash_drop.py (--drop-dir=) [--factory-reset=]…
Jack
  • 722
  • 3
  • 8
  • 24
0
votes
1 answer

Docopt extreemly unintuitive opions usage

Docopt loves to write lots of documentation, by I can't seem to find a single actual command line call inside their many pages of how to write the comments section. I have this very simple file: """Main.py Usage: main.py controller main.py…
Alexander Kleinhans
  • 5,950
  • 10
  • 55
  • 111