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
1 answer

Why does Python docopt say "-c requires argument" here?

Python docopt works OK for simple cases, but in this case it keeps saying -c requires argument, despite it having an argument. Minimal code (Python 3.6): '''Usage: test_docopt.py x YYY ZZZ [-a AAA] [-b BBB] [-c CCC] Options: -a AAA description …
nerdfever.com
  • 1,652
  • 1
  • 20
  • 41
0
votes
1 answer

Python cli module import not found

I am trying to run a packaged cli, which does dynamic imports. When I run the code through the main cli script it works as expected. However after I package the code up using setup.py sdistand then install the dist tar with pip. The cli itself gives…
user3116846
  • 77
  • 1
  • 3
  • 7
0
votes
1 answer

Docopt: why this usage is not parsed?

My usage: Usage: prog at ( []) [(before )] (alarm|email) My command line args: at 4 alarm It seems clear to me that the appearance of at and alarm locates the ambiguous value 4 to be either v1 or v2. And since v2 will always be led…
Roy
  • 880
  • 1
  • 12
  • 27
0
votes
1 answer

How to frame unordered arguments in docopt?

I'm trying to frame a docopt usage which accepts set of options. Naval Fate. Usage: naval_fate.py ship [-b ] [-e ] Runnable example:…
pinkpanther
  • 4,770
  • 2
  • 38
  • 62
0
votes
0 answers

Trying to understand docopt(__doc__)

So I am trying to learn Python but I am a little bit overwhelmed with many new things. One of these things that I am not able to understand is: if __name__ == '__main__': args = docopt(__doc__) print(args) The results of the print function is…
Ahmed Ali
  • 127
  • 2
  • 13
0
votes
1 answer

Is there a way to use docopt to pass a vector of u8 from the command line?

Is there a way to make the user prompt for the bytes inside brackets and separated by commas or something similar? ./main bytes [0, 1, 2, 3, 4, 5] I managed to make it look like this: ./main bytes 0 1 2 3 4 5 This is my code: extern crate…
0
votes
1 answer

How to add an optional parameter with a mandatory field, if chosen?

I use docopt to handle the arguments of my scripts. I have a case where I would like to allow to "add" or "delete" something in my script. The "add" or "delete" action is not manadatory, but if either is chosen then it requires a parameter (the…
WoJ
  • 27,165
  • 48
  • 180
  • 345
0
votes
1 answer

How to use the actual invocation of the program in Python docopt usages?

I am trying to use the docopt module in Python to parse command-line arguments for a script. This script may be called directly, or via a .exe built with PyInstaller. I want to use the actual name of the program in the usage section, which is…
l k
  • 117
  • 8
0
votes
1 answer

How do i start to implement docopt to my python class

I have the following python class working and i want to create a command line interface for the user to use. I came across docopt and thought it was a good idea to use. I haven't come across a tutorial or documentation showing how to integrate…
Nix
  • 203
  • 1
  • 3
  • 14
0
votes
2 answers

Test python cli wheel package during local development

I'm developing a CLI tool in python using docopt and packaging via wheels. I can build and install the wheel package locally with the following: python setup.py sdist bdist_wheel pip install dist/mypackage.whl I can then test my package from the…
duncanhall
  • 11,035
  • 5
  • 54
  • 86
0
votes
1 answer

Docopt - Script exits to early

I recently found this package (docopt), but i cant seem to get it to work properly. Any help what so ever is appreciated. The code: """docopt_demo. Usage: docopt_demo ... docopt_demo --version """ from docopt import docopt arguments =…
Olian04
  • 6,480
  • 2
  • 27
  • 54
0
votes
1 answer

Docopt | Google Drive Api Integration Issue

I am new to command line tools. I am trying to build a Google Drive command line client. I am trying to use Docopt. This is what my main file looks like: """ GDR Google Drive Command Line Client. Usage: gdr.py about gdr.py upload
0
votes
1 answer

docopt interprets any -v as version

I am creating a cli with docopt and have the following issue (I'll bring in examples from their naval_fate example cli) naval-fate --version or naval-fate -v will return the cli version but when try doing let's say naval-fate ship -v for a different…
Narine Cholakian
  • 189
  • 1
  • 2
  • 13
0
votes
2 answers

How do I work with "end of options" in docopt?

I'm using docopt and python 2.7. I want to implement something similar to -- in vim. From man vim: -- Denotes the end of the options. Arguments after this will be handled as a file name. This can be used to edit a filename that starts…
DJMcMayhem
  • 7,285
  • 4
  • 41
  • 61
0
votes
2 answers

Behaviour of the docopt module (argument parser)

I currently use the docopt lib for the first time so I surely do something wrong My script is : """prog Usage: prog.py (-h | --help) prog.py (--version) prog.py -s TAG [-t NB_NUC] Options: -h, --help help --version …
Liad
  • 340
  • 4
  • 15