Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warning message incomprehensible for end-user #5

Open
thorstenkampe opened this issue Sep 27, 2019 · 5 comments · Fixed by #37
Open

Warning message incomprehensible for end-user #5

thorstenkampe opened this issue Sep 27, 2019 · 5 comments · Fixed by #37

Comments

@thorstenkampe
Copy link

thorstenkampe commented Sep 27, 2019

Wenn I run my script without a necessary subcommand, docopt-ng issues a warning - shouldn't it be an error? - which in my opinion is not suitable for the enduser (found unmatched (duplicate?) arguments [Argument(None, '...')].

Even I as the script writer, don't know what that exactly means. It looks to me like docopt-ng exposes internals from the parsing process which should not be given to the script user.

> python interpreter.py '.\10. PowerShell.ps1'
Warning: found unmatched (duplicate?) arguments [Argument(None, '.\\10. PowerShell.ps1')]
Usage:
 interpreter.py run <script> [-- <script_option> ...]
 interpreter.py doc [-s <text>] <script>
@loelkes
Copy link

loelkes commented Nov 7, 2019

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.

@jambonrose
Copy link

jambonrose commented Jan 15, 2020

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

@traviswaelbro
Copy link

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.

@FelixSchwarz
Copy link

This is really the most annoying issue in docopt-ng for me. The warning is also shown when a user mistypes an parameter (e.g. --dryrun instead of --dry-run) and the error message is almost impossible to understand as an end user.

@NickCrews
Copy link
Contributor

I agree this is an issue, I would like to see it fixed. I am unlikely to implement it myself in any immediate time frame, but I will happily review any PRs people submit! Please start them small and get feedback quickly, I don't want you to waste your time. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants