-
Notifications
You must be signed in to change notification settings - Fork 650
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
NDesk.Options - spike for better command line argument handling #572
Conversation
AS of now, does not compile bco treat warnings as errors or similar project setting.
With validation
But this is not backwards compatible.
Conflicts: src/GitVersionExe/ArgumentParser.cs
Note that 6e1db37 is NOT backwards compatible. |
@JakeGinnivan I like the state of this PR at 6e1db37. However, this is a breaking change. It would break any client doing:
That's currently supported. What does work is:
More specific, A complete list of accepted arguments can be reviewed here. We can only support this if we include it as another special case, which would result in some not-so-pretty-yet-easily-identifiable code. Suggestions? Do we need to be fully backwards compatible? |
Just a thought, I'm not sure if it's possible or good way, but here's my idea. What about patching the args so they'll work with the new parser? If this is possible it's easy to display that some arguments are deprecated and will be removed in a future version?
|
@orjan yeah, I did that for other args such as the positional args "init" and "path". I can do that for |
Before we make this decision, I think we need to look at the command line args again. If we were to go back to the drawing board and come up with new command line arguments, how much better would they be than what we have now. If we can make a drastic improvement to the command line usage by completely breaking it and bumping to v4, then I am leaning towards doing that. We could always create a GitVersionCompatShim.exe which provides backwards compatibility on a command line level. |
If one of you could come up with what a rethought out command line structure looked like, that would be a great step towards the compat decision |
OK, I'll cook up an overview of proposed command line interface, indicating breaking changes. |
FWIW I have never liked NDesk.options. it is abandonware and the syntax is ugly and convoluted. Eg the git repo link here http://www.ndesk.org/Options is dead, even the forks, and the forks of the forks, are abandonware https://github.com/mwpowellhtx/NDesk.Options.Extensions https://github.com/gibbed/NDesk.Options https://github.com/nano-byte/NDesk.Options https://github.com/hach-que/NDesk.Options I would much prefer something like this https://github.com/gsscoder/commandline So what other choices apart from NDesk.options were considered? |
I know the guys who run Cake are thinking about using the Configuration options that are being cooked up as part of ASP.NET 5 for their tool: https://www.nuget.org/packages/Microsoft.Framework.Configuration/1.0.0-beta6 https://github.com/aspnet/Configuration https://gitter.im/cake-build/cake?at=55b919a622f1cbba636fb1a9 Was it considered? |
@SimonCropp afaik NDesk.Options was adopted by the Mono project, see here, history and adoption post from the Mono lead. I was triggered by this remark requesting for a code dependency instead of nuget/binary dependency. I have not thoroughly considered all command line argument parsers out there, but just went with one I was familiar with. I considered:
FWIW I don't intend to do a thorough comparison of all command line argument parsers out there. If anyone has a good reference of such a comparison or a strong preference just let me know and I'll be happy to implement it. IMO if we use a lib with a proper command line interface (like Mono.Options has) and keep it decoupled well (which the current codebase allows us to do very well BTW, good job there), this can't really hurt us. In fact, this decoupling is wat kept me from picking the CommandLineParser-like API, because the use of attributes IMO give us stronger coupling than we need to the argument parsing library. Looking forward to your reactions! |
I think you could probably implement all of those parsers in a loosely I havent used ndesk but CommandLineParser is awesome. On Mon, 17 Aug 2015 16:10 Marijn van der Zee notifications@github.com
|
For me I want to see what the ideal command line args looks like. We should be aligned with git in terms of With a rethought cli then we can make the decision if we want to make a breaking change to switch, or if the gains are not worth it? |
@JakeGinnivan I'll write up a proposal today. |
@JakeGinnivan this proposal assumes the same functionality. It is not revolutionary, but more consistent across the cli and allows for extension and renaming. Main breaking change is that we drop the positional path and init arguments. Breaking changes are marked with an asterix in the description. I can imagine implementing this without breaking changes, which would have the downside of some ugly code and an inconsistent cli wrt the I'd consider it an improvement if option names were better readable, but this can easily be achieved later by specifying aliases for the options and later phasing out bad names along with other breaking changes. I lack the foresight on what's coming for gitversion. But given the current feature set I'd stick with the current options-only CLI over a verb+options cli (eg git commit -m "intial commit"). If you do foresee the need for this, we should reconsider this proposal.
|
some examples
|
What about having a more command focused cli, this would align better with git, nuget, npm etc
If no command is given then run is the default. Then we can show much less when you say Thoughts? |
Then run becomes interesting. I don't like the |
OK, so anything is open? Agree wrt output and log. I like the command style cli, but those get messed up IMO when not sticking to verbs (add, commit, log). And they shine for clis to application with much functionality, whereas gitversion is pretty focused. But it's definitely worth a try. I'll give it some thought and let go of the current cli. |
Small improvements -> Lets try and keep compatible Before trying to get small gains I want to see if we can rethink it to make it a bit more intuitive |
Fyi, there's also PR pending for a possible command line tool in the BCL (dotnet/corefxlab#280). |
I saw that! Looks quite good actually. Need to get back onto this, will try later this week once I sort out Shouldly and TestStack.BDDfy |
Work in Progress
This is a spike for #428 to use NDesk.Options to parse command line arguments.
This is the same command line argument parser as used in the Mono project.
First step is to see if we can incorporate this while being completely backwards compatible. This will give us the benefit of a cleaner argument-parsing code base immediately. And it will als allow to add shortcuts immediately and without any pain.
So far seems NDesk.Options can be used while being completely backwards compatible. I think it will take me a couple of hours more to get to a completely backwards compatible implementation.
issues to address
-updateAssemblyInfo
takes optional parameter. This is a bit hard to fix while maintaining full backwards compatibility, because for optional values, the notation-updateassemlyinfo filetochange.cs
is not allowed; only-updateassemlyinfo:filetochange.cs
or-updateassemlyinfo=filetochange.cs
. We can only support this if we include it as another special case. (that means excluding it from the option set and handle it as an additional argument)-execArgs
is case sensitive; tested with bothexecargs
andexecArgs
; probably should create case insensitive option set for backwards compatbilityAlthough only -o --option arguments are listed, /o and /option are supported too.