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

docopt required options and options with arguments

I am new to docopt and am having a bit of difficulty getting a small example working. I'm having two small problems just now and would welcome assistance on those problems and more general comments on improving the code. The first problem is getting…
d3pd
  • 7,935
  • 24
  • 76
  • 127
0
votes
1 answer

Docopt: Is it possible to specify repeating positional argument followed by a single positional argument?

I have a simple python script that uses docopt to parse command line arguments. It looks like this: #!/usr/bin/env python __doc__ = """ Usage: mycopy ... """ from docopt import docopt options = docopt(__doc__) When I run it: ./mycopy…
Dan Keder
  • 684
  • 5
  • 8
0
votes
2 answers

Formatting Usage with Docopt

I am having a problem with my usage statements in docopt. This is how I'd expect usage to work in the script. The optional parameters (defined with []), I would like to be able to use them together or individually. So -t -o or -o or -t should be…
iNoob
  • 1,375
  • 3
  • 19
  • 47
0
votes
1 answer

Python docopt usage menu issues

Im getting an error i believe is being caused by my usage descriptions but cant work out why. The idea is to grab a list of valid users in a file (username password), split that into a dictionary and return the dictionary. Then grab a file of…
iNoob
  • 1,375
  • 3
  • 19
  • 47
0
votes
2 answers

Error handling with verbose output

Im trying to implement the --verbose option in my script. The idea is to turn on extra printing of errors etc for debugging, but for some reason it doesnt seem to work. Ive tried a few variations of the if verbose statement but no joy. Im hoping…
iNoob
  • 1,375
  • 3
  • 19
  • 47
0
votes
2 answers

Defining Argument values with docopt

Im working on my first python "app" and after some advice from the participants on Stackoverflow. Ive decided to scrap what I had and start from scratch. It seems to be parsing the arguments nicely for usage etc but im not sure how I am meant to…
iNoob
  • 1,375
  • 3
  • 19
  • 47
0
votes
1 answer

Docopt - one ore more options are required

I have three arguments: --a --b --c and I want my command to accept at least on of them but all combinations of a/b/c are also valid. E.g: command.py --a command.py --a --b command.py --a --b --c ... but not without arguments: command.py Thanks!
Bruce
  • 1,380
  • 2
  • 13
  • 17
-1
votes
2 answers

Postional arguements in python Docopt

I am writing a simple command line contact manager. i want to be able to add a new contact with the following command. manager.py add -n NAME -p PHONENUMBER but whenver i add a contact using firstname and lastname, the code throws errors. eg.…
-1
votes
1 answer

Quote marks in args for littler/docopt

I want to pass strings like key="value" to a littler script. In bash, I have argtest.sh: #!/bin/sh echo $1 which I can call, preserving the quotes from the shell by backslashes, and I see them in the output: $ ./argtest.sh x=\"1\" x="1" However I…
Spacedman
  • 92,590
  • 12
  • 140
  • 224
-2
votes
2 answers

curl command to python dict

I am a backend dev at my current company. When the front-end team has an issue, they will sometimes use Chrome devtool's "copy request as curl" feature and send me the problematic curl request. I was thinking it would be cool if I could write a…
Jesse Aldridge
  • 7,991
  • 9
  • 48
  • 75
-2
votes
4 answers

Replacing sys.argv with docopt

I'm working on incorporating some string replacements and currently arguments are passed to my script using sys.argv[i]. I'd like to replace sys with docopt, but I've found the documentation relatively unclear so far. The way my code currently works…
PhysicistAbroad
  • 185
  • 1
  • 8
-2
votes
1 answer

How to enter command line argument with docops?

How can I enter command line arguments in Rust using docopts? I'd like to simply be able to enter a u8 in a vector and parse it with docopts.
Lexka
  • 359
  • 1
  • 3
  • 9
1 2 3
9
10