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

Eliminate the ambiguity of "-h" option #563

Merged
merged 2 commits into from
Jul 18, 2024

Conversation

myd7349
Copy link
Contributor

@myd7349 myd7349 commented Jul 16, 2024

Currently, the "-h" option serves as an alias for both "--headerFile" and "--help" long options, causing ambiguity.

When entering "ClangSharpPInvokeGenerator -h" in the command line, it prompts:

Required argument missing for option: '-h'.

However, entering "ClangSharpPInvokeGenerator --help" outputs the help information correctly.

To eliminate ambiguity, we have three options:

  1. Use "-h" as the short version of "--headerFile".

    In this case, since "-h" cannot serve as the short version of "--help" anymore, we cannot rely on the default help message generated by System.Commandline. This aligns with the current behavior of "-h" as well.

  2. Use "-h" as the short version of "--help".

    In this case, we must change this line:

    private static readonly string[] s_headerOptionAliases = ["--headerFile", "-h"];

    either delete the "-h" alias or use a different one(-H or -hf, for example).

    (BTW, if we think -hf is a good option name, should we change the long version to --header-file?)

  3. Replace --headerFile to another name, so that we can use a short option which is not -h.

This pull request adopts solution 1. Please let me know if you have any other preferences.

@myd7349
Copy link
Contributor Author

myd7349 commented Jul 16, 2024

BTW, this still works:

ClangSharpPInvokeGenerator -c h

@myd7349
Copy link
Contributor Author

myd7349 commented Jul 16, 2024

TODO: Update ClangSharpPInvokeGenerator usage in https://github.com/dotnet/ClangSharp/blob/main/README.md#generating-bindings.

@tannergooding
Copy link
Member

2 is the better option here, IMO.

-h is a very common shorthand for help and so having --headerFile default to something like -hf is overall less problematic.

@myd7349
Copy link
Contributor Author

myd7349 commented Jul 17, 2024

2 is the better option here, IMO.

-h is a very common shorthand for help and so having --headerFile default to something like -hf is overall less problematic.

Hi. Thanks. I will update this PR soon.

Currently, the "-h" option serves as an alias for both
"--headerFile" and "--help" long options, causing ambiguity.
@myd7349
Copy link
Contributor Author

myd7349 commented Jul 18, 2024

Hi. @tannergooding I have updated the PR.

The usage for ClangSharpPInvokeGenerator in README.md has also been updated to synchronize with the output of --help and -c help.

@tannergooding tannergooding merged commit 006106b into dotnet:main Jul 18, 2024
13 checks passed
@myd7349 myd7349 deleted the fix-h-option-ambiguity branch July 18, 2024 17:06
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 this pull request may close these issues.

2 participants