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

Cannot retrieve filenames using Python docopt library

I am reading the book Violent Python and one example is a zip file cracker, which tests a dictionary file of potential passwords (a text file) against a zip file. I am trying to use the docopt library to parse the command line and give me the…
ravenwingz
  • 117
  • 1
  • 2
  • 11
0
votes
1 answer

Specify valid values for arguments using docopt

I am trying to use docopt for the first time. So far, this is the usage statement I have: Test Control Program Usage: test.py bitwrite ([--off=...][--on=...]) test.py regwrite ([regA | regB]) Options: -o ... --off…
Rob Hix
  • 37
  • 5
0
votes
1 answer

docopt not working and proceeding

The following version 0.6.2 docopt string is not working although i dont find any error in it: """Usage: somecommand.py [-n nos] [-u] [-c] [-s start] Options: -h show help -u some reply -n number to fetch -c ask to do it …
stackit
  • 3,036
  • 9
  • 34
  • 62
0
votes
1 answer

How to enforce docopt to parse one option only?

folks! I am trying the docopt (cpp variant). I have tried this variant: Usage: prog [-o | --out-file=] prog -h | --help prog --version Options: -h --help Show this screen. --version …
Serge Roussak
  • 1,731
  • 1
  • 14
  • 28
0
votes
1 answer

using multiple args with docopt

I'm trying to use docopt so a user can do an input like: python3 -p argum1 -d argum2 [-u arg_facul] the arguments argum1 and argum must not be positional; the first two arguments are required and the third is optional. I already have this: """…
0
votes
1 answer

docopt positional mandatory arguments keeping delimiters in name?

I'm trying a very simple python script with only positional arguments, handled by docopt. #!/usr/bin/env python opt_spec = """Test Usage: docopt_test (import | export ) docopt_test (-h | --help) …
André Fernandes
  • 2,335
  • 3
  • 25
  • 33
0
votes
1 answer

Getting Console Input with Ruby's Docopt

I'm using Docopt in Ruby to parse my command options, and later in the script I am getting console input using gets.chomp. The problem is that all of the args from the running the program are still left in ARGF after Docopt does its parsing with…
0
votes
1 answer

Is there a built-in way to detect wheter a user changed the default value of an option in docopt?

Suppose one has the following code: #!/usr/bin/python """Does something. Usage: myprog.py --myopt= Options: --myopt= Some option [default: bla] """ arguments = docopt(__doc__) print arguments Is there a way to check whether…
con-f-use
  • 3,772
  • 5
  • 39
  • 60
0
votes
0 answers

how to unwrap lines of a docstring

I am using the module docopt but need to have line-wrapping in the main docstring of my programs. In order to pass this line-wrapped docstring to docopt, I want to 'unwrap' the lines of my docstring in a sensible and robust way such that docopt can…
d3pd
  • 7,935
  • 24
  • 76
  • 127
0
votes
1 answer

Parsing docopt argument types (any language)

I have a use case where users provide a docopt string, and based on it, I generate some code. So I do not know my docopt string up front. For certain "argument types" (not datatypes), I wish to generate various code. In the following, I will…
jkgeyti
  • 2,344
  • 18
  • 31
0
votes
1 answer

Repeating arguments specified in options list

Is it possible to do something along the lines of: Usage: program submit [options] Options: --user Users email address --documents ... Documents to submit (can enter multiple) submit --user Austin --documents…
arc
  • 477
  • 2
  • 8
  • 14
0
votes
1 answer

Does DocOpt support the @FILE syntax for supplying a file with additional CLI options?

The title says it all! I can't seem to find this in any of the documentation nor on any other sites/SO questions. What I want to do is when calling my program, specify a file that contains more CLI options. It is supported in some UNIX programs…
Caleb
  • 870
  • 1
  • 10
  • 21
0
votes
1 answer

Include spaces in program name in docopt

How can one include program names with spaces (like git status) in docopt? I have a setup where a Perl script dispatches a Python script. The Perl script can be called in many ways, let's say for simplicity: prog sub1 sub2. So the Perl script is…
Håkon Hægland
  • 39,012
  • 21
  • 81
  • 174
0
votes
1 answer

TypeError: execv() arg 2 must contain only strings using docopt

I am running into following error while passing arguments. Can anyone help me identify this problem? I'm passing instructions to my function in terminal like this: python makeQuicktime.py -i…
Mateusz Wójt
  • 109
  • 2
  • 15
0
votes
1 answer

Docopt - Errors, exit undefined - CLI interface for Python programme

I'm sure that the answer for this is out there, but I've read the site info, I've watched the video they made and I've tried to find a really basic tutorial but I can't. I've been messing about with this for most of the day and It's not really…
baxx
  • 3,956
  • 6
  • 37
  • 75
1 2 3
9
10