Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9027053
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T06:40:01+00:00 2026-06-16T06:40:01+00:00

I’ve been trying to use docopt to make a simple CLI, but for some

  • 0

I’ve been trying to use docopt to make a simple CLI, but for some reason my default parameters are not appearing. Below is my test code. I am using the latest version of docopt.py from the github repository.

"""
Usage:  scrappy <path> ... [options]

-a --auto           Automatically scrape and rename without user interaction.
-l --lang           Specify language code [default: en].
--scan-individual   Evaluate series information individually for each file.
-c --cfg            User alternate config file [default: ../scrappy.conf]
-t --test           Test run.  Do not modify files.
-v --verbose        Print verbose output
"""

from docopt import docopt
arguments = docopt(__doc__, version='0.1.0 alpha')
print arguments  # DEBUG

Here’s my output when I run $ scrappy/scrappy.py first_path_parameter second/path/parameter

{'--auto': None,
 '--cfg': None,
 '--lang': None,
 '--scan-individual': None,
 '--test': None,
 '--verbose': None,
 '<path>': ['first_path_parameter', 'second/path/parameter']}

Anybody know what’s going on?

EDIT:

I updated my code, but I’m still getting similar output. What’s more, when I try to pass --scan-individual, I get an error according to which it requires an argument. Again, in case it matters, I’m running docopt having simply copied docopt.py into the working directory of my project. What’s going on, here?

#!/usr/bin/env python

"""Scrappy:  Rename media files based on scraped information.

Usage:  scrappy <path> ... [options]

-a --auto               Automatically scrape and rename without user interaction.
-l LANG --lang LANG     Specify language code [default: en].
--scan-individual       Evaluate series information individually for each file.
-c CONF --cfg CONF      User alternate config file [default: ../scrappy.conf]
-t --test               Test run.  Do not modify files.
-v --verbose            Print verbose output
"""

from docopt import docopt
arguments = docopt(__doc__, version='0.1.0 alpha')
print arguments  # DEBUG

Output:

$ scrappy/scrappy.py first_path_parameter second/path/parameter --scan-individual
--scan-individual requires argument
Usage:  scrappy <path> ... [options]
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T06:40:02+00:00Added an answer on June 16, 2026 at 6:40 am

    By looking at the examples, it seems that if you want to pass a default value you may have to specify a target variable, e.g.

    naval_fate.py:  --speed=<kn>  Speed in knots [default: 10].
    options_example.py-  --exclude=PATTERNS   exclude files or directories which match these comma
    options_example.py:                       separated patterns [default: .svn,CVS,.bzr,.hg,.git]
    options_example.py-  -f NAME --file=NAME  when parsing directories, only check filenames matching
    options_example.py:                       these comma separated patterns [default: *.py]
    

    So in your case,

    -l LANG --lang LANG  Specify language code [default: en].
    -c CONFIG            User alternate config file [default: ../scrappy.conf]
    

    produces

    localhost-2:coding $ python doc.py --auto a b c
    {'--auto': True,
     '--lang': 'en',
     '--scan-individual': False,
     '--test': False,
     '--verbose': False,
     '-c': '../scrappy.conf',
     '<path>': ['a', 'b', 'c']}
    

    Edit: the updated code the OP posted works just fine for me, with the github version I downloaded about half an hour ago:

    localhost-2:coding $ ./scrappy.py first_path_parameter second/path/parameter --scan-individual
    {'--auto': False,
     '--cfg': '../scrappy.conf',
     '--lang': 'en',
     '--scan-individual': True,
     '--test': False,
     '--verbose': False,
     '<path>': ['first_path_parameter', 'second/path/parameter']}
    

    So I’m at a loss.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
Seemingly simple, but I cannot find anything relevant on the web. What is the
I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I am confused How to use looping for Json response Array in another Array.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.