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

Add setting to interpret options starting with a single dash as long named options #767

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from

Conversation

MichaeIDietrich
Copy link

This PR adds a setting to use single dashes for command line options.

As several others in issue #685 we wanted to switch to this library, since it is more robust than other libraries available. But due to backwards compatibility we needed to support single dashes instead of double dashes for options else we would break our customer's scripts.
So we forked this library and added an option for single dash support and now would like to bring this to the official repo.

There is a new setting OptionsParseMode in ParserSettings

With three modes:

  • Default is identical to the current behavior

Options that start with a double dash must be defined using their full name.
(e.g. git rebase --interactive)
Options that start with a single dash are interpreted as list of short named options.
(e.g. git clean -xdf)

  • SingleOrDoubleDash

Options that start with a single or double dash are interpreted as short or full named option.
(e.g. git rebase --interactive or git rebase -interactive or git rebase --i or git rebase -i, but git clean -xdf would no longer be possible)

  • SingleDashOnly

Options that start with a single dash are interpreted as short or full named option.
(e.g. git rebase -interactive or git rebase -i )
Options that start with a double dash are considered as an invalid input.
(e.g. git rebase --interactive would no longer be possible)

It would be great if you could consider this feature, since there are several library consumers that are looking for this option.

@ericnewton76
Copy link
Member

Thank you for submitting.

Your pull request looks comprehensive, and good job with adding the tests. I believe this warrants a minor version bump to 2.10

I'm a little apprehensive about deviating from the original getopt specs but I do see the benefit of migration (ahem Nuget.exe) and similar.

@MichaeIDietrich
Copy link
Author

Oh great, it would be really nice if this could be merged, so there is no need for our dev team to maintain a local fork anymore.
I will have another look on this PR next week. If I remember correctly, there was bug we have already fixed in our local fork.
If so, I'll update the PR and report back. 👍

@MichaeIDietrich
Copy link
Author

MichaeIDietrich commented Sep 12, 2022

OK, I updated the PR. There were hard coded occurrences of --help and --version that I missed before. But now they are also handled correctly in respect to the used mode.

By the way this new mode is almost in use for one year in our business application and we received no issues from our customers, so it is kind of tested externally already. :)

So from my perspective this PR is ready to be merged, if you don't have any further suggestions.

@josesimoes
Copy link

josesimoes commented Nov 29, 2022

Any chance this can be reviewed and merged? It would be a very much welcome improvement!

@daniel-flemming
Copy link

This PR does exactly what we want to achieve in our application. It would be great if single dashes would be an option in the CommandLine library. We really like the functionality and how this library provides an easy to use and easy to maintain command line support. Unfortunately we also have the hard requirement to use single dashes.

Merging this would be great :-)

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.

4 participants