Code Monkey home page Code Monkey logo

Comments (3)

loelkes avatar loelkes commented on June 6, 2024

I had the same issue but fixed it through trial and error. I had something like this:

Usage:
  script.py (--save | --load) FILE

Arguments:
  FILE                     

Options:
  --save FILE
  --load FILE

The error message was:

$ python script.py --save file.ini
Warning: found unmatched (duplicate?) arguments [Option(None, '--save', 1, 'file.ini')]

Removing FILE after --save in Options: did the trick for me.

from docopt-ng.

jambonrose avatar jambonrose commented on June 6, 2024

The error message presented is confusing.

Provided the following:

"""CLI

Usage:
  cli <arg1> <arg2>

"""
from docopt import docopt


def main():
    """MVE of confusing error"""
    arguments = docopt(__doc__, version="1.0.0")
    print(arguments)


if __name__ == "__main__":
    main()

The command line behavior is:

$ cli 
Usage:
  cli <arg1> <arg2>

$ cli 1 2
{'<arg1>': '1',
 '<arg2>': '2'}

$ cli 1 
Warning: found unmatched (duplicate?) arguments [Argument(None, '1')]
Usage:
  cli <arg1> <arg2>

The error message provided above should instead tell the command-line user that they need to specify a second argument.

I note for clarity that the help and version features work despite being undocumented.

$ cli --help
CLI

Usage:
  cli <arg1> <arg2>

$ cli -h
CLI

Usage:
  cli <arg1> <arg2>

$ cli --version
1.0.0

from docopt-ng.

traviswaelbro avatar traviswaelbro commented on June 6, 2024

I was running into this issue as well and it ended up being because I was calling docopt(..., options_first=True, ...) and it was evaluating differently than I expected, which was causing the unclear error message. Removing that option resolved it in my case.

from docopt-ng.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.