-
Notifications
You must be signed in to change notification settings - Fork 653
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
[Feature] New CLI #2275
Comments
For this one, what would overriding multiple config values look like?
|
I think the cleanest is to repeat the argument: gitversion calculate --override-config tag-prefix=foo --override-config next-version=1.2.3 --override-config mode=Mainline We might go for colon gitversion calculate --override-config tag-prefix:foo --override-config next-version:1.2.3 --override-config mode:Mainline Not sure. |
@asbjornu I think System.CommandLine supports both : and = https://github.com/dotnet/command-line-api/wiki/Syntax-Concepts-and-Parser#delimiters |
it's up to the user to decide which syntax they prefer. For our docs we'll need to choose one syntax to be consistent |
Sorry if I wan't entirely clear on where the separator occurs. I meant the separator between the key and the value in the value for the argument Afaict, the separator being discussed is between the argument and its value, i.e. the space between But I think |
Actually I remember they had a way to parse that too, as the intent is to be able to have something similar to the dotnet build --property:name=value, the way they pass properties to msbuild |
Neat. Perhaps we should just drop |
I just discovered docopt which may be worth considering for the argument parsing. |
The current POC is done in the new-cli folder |
btw, instead of docopt, i would suggest CommandLineParser library: https://github.com/commandlineparser/commandline I help manage that library. |
@ericnewton76 we decided to go with System.Commandline, and on the mentioned branch we're already working on that |
BTW, I suggested in #3184 to add an option for flat output as opposed to JSON, via something like Also, UPDATE 2022-09-22: I think I read the porcelain stuff wrong in git docs, --porcelain seems to imply a user interface and might change so not good for scripting. I happen to be reading this doc: https://www.git-scm.com/docs/git/2.36.0#_low_level_commands_plumbing and it seems to imply porcelain is UX and might change. |
BTW, I was just thinking, its been mentioned that certain operations might require multiple runs which makes sense for certain types of operations. In doing so, I would setup the scenario where, by default, the output of the version resolution is stored (as the environment variable, GITVERSION_SEMVER?) and subsequent runs could skip the version resolution because this environment variable is present... from the previous run Unless an option like This would support additional scenarios where updating particular types of files can be separated. For instance, we had a VersionStamp.py script that could inject the already set env.MAJOR_MINOR_PATCH into various files that we displayed the version to the user, like MainTemplate.master, docs/MyProgram.html, etc. My thought was a more generic file updater (considering AssemblyVersionUpdater) could be implemented with a more generic use of tokens. So for example, inside MainTemplate.master we see
|
If you read my examples, I've already suggested using |
Might be worth adding one more - the ability to pass the gitversion config as STDIN to
|
I think we have this one instead |
@arturcic fair.
Not an important scenario for me personally, not sure if this flexibility is particularly sought after! The above is still possible with the way the command is currently proposed ofcourse but it would require the config be saved by the user to a file on disk first and then the path of that config passed to the calculate command, not a huge deal but not as nice imho. |
I wanted to throw in my thoughts here. If we use the Microsoft recommended Dockerfile for modern .NET, they load the entire source repo into the docker context. This is primarily to build the application, but the This is mostly a performance concern for me. There's no other reason to have the |
Detailed Description
This issue is our explorations of how the new CLI of GitVersion
67 is going to look like.Design
The new CLI is going to have a command-based style, allowing for more laser-focused and composable execution. We want
stdin
andstdout
to become the default way to both read and write version variables, logging instead tostderr
sostdout
can be kept as valid JSON throughout.Since we want to reduce the amount of work being done for each command, GitVersion may have to be executed several times for certain builds, perhaps introducing some latency, but also making it much easier to pinpoint exactly during which step an error occurs so we can fix more easily and users of GitVersion can circumvent and monkey-patch the bugs much more efficiently.
Architecture
The new and more laser-focused command-based CLI allows us to refactor the GitVersion codebase into smaller, more compartementalized parts. This should lead to an almost dependency-free
Core
with a few optional addon projects that can live their own lives. The API betweenGitVersion.Core
and the addons will be based on the CLI infrastructure we choose. Our current bet is onSystem.CommandLine
.Addons will be able to add their own commands to GitVersion and besides the
Command
implementations and arguments they can add to it, they will be able to read the version variables produced by GitVersion as JSON and then perform whatever task they wish. The output from an addon should be JSON written tostdout
so different commands can be composed with piping.Possible Implementation
Below is an example of some of the commands the new CLI may support, with some of their corresponding arguments.
Related Issue
#358, #428, #598, #572.
Motivation and Context
The CLI of GitVersion is a road that has been built as we have walked it, with no planning and no idea of scope or feature set before implementation was started. It has proved difficult to support POSIX file systems due to forward slash
/
being chosen as the argument separator originally, the argument system doesn't allow for easy documentation generation and perhaps most importantly: Argument parsing is not a core concern of GitVersion, so we're best served to outsource this entire thing to a third-party library.The text was updated successfully, but these errors were encountered: