Skip to content

I get "Option 'version' is unknown" if it comes after other user-defined options on the command line #661

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

Open
gbirchmeier opened this issue Jul 7, 2020 · 6 comments

Comments

@gbirchmeier
Copy link

Since version is pretty much built-in, it should never be "unknown", especially if this message is immediately followed by helptext that clearly shows that it is a valid option.

3676 ~/fork/foo-etl$ dotnet etl/bin/Debug/netcoreapp3.0/etl.dll -c foo -d bar --version
etl 0.0.1
Copyright (C) 2020 etl

ERROR(S):
  Option 'version' is unknown.

  -c, --configdir     Required. Path to dir that contains client configurations

  -d, --invoicedir    Required. Path to dir that contains invoices are

  --help              Display this help screen.

  --version           Display version information.
@gbirchmeier gbirchmeier changed the title I get "Option 'version' is unknown" if it comes after user-defined options I get "Option 'version' is unknown" if it comes after other user-defined options on the command line Jul 7, 2020
@moh-hassan
Copy link
Collaborator

What do you think to fix this issue:

  1. ignore --version or --help if it's not called in the correct way, and don't raise error.
    that what is done in most of tools.
    e.g dotnet --info --version //ignore --version
  2. Give a priority to --version or --help whatever it's located in the commandline and executing its action ( ignoring other options).
  3. Raise error "Invalid version/help command"

@gbirchmeier
Copy link
Author

Comments on each suggestion:

  1. There is a "correct" way? How does a user know what the correct way is? The help doesn't say that there is a correct way.
  2. If it went this way, I'd say it also needs to print "All other parameters ignored when --help and --ignore are present."
  3. Same as 1: this message is bad because the user doesn't know why it's invalid.

An alternate suggestion:

If "--version" is present, can the app print the version as the very first action, and then let the app proceed as normal?

@moh-hassan
Copy link
Collaborator

moh-hassan commented Jul 8, 2020

There is a "correct" way? How does a user know what the correct way is? The help doesn't say that there is a correct way.

Help screen is short and it's supposed that user manual of the tool describe how to use these options in detail in a correct way.
we can insure in wiki the correct /invalid usage of --version /--help.
The commands --version and --help are becoming standard in GNU Standard.

If "--version" is present, can the app print the version as the very first action, and then let the app proceed as normal?

--Version /Help are separate commands and most of the CLI tools don't work in this way. for example: `dotnet --info --version' run info not the version command.

@moh-hassan
Copy link
Collaborator

I think option 2 is reasonable especially it math GNU standard.
I'll wait to listen from the community for the suggested solutions for this issue.

@gbirchmeier
Copy link
Author

gbirchmeier commented Jul 20, 2020

I've just read the GNU standard regarding command-line params.

I now agree with you that (2) is the best option: params --help and --version should cause all other params to be ignored.

Since --help's output includes the version, --version can be ignored if both are present.

@rmunn
Copy link
Contributor

rmunn commented Aug 19, 2020

This is fixed by #686, which allow --help and --version to appear anywhere on the command line rather than only being handled in first position.

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

No branches or pull requests

3 participants