-
Notifications
You must be signed in to change notification settings - Fork 662
Adopt POSIX-style CLI arguments #4840
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
Merged
arturcic
merged 24 commits into
GitTools:next/v7
from
arturcic:feature/posix-argument-parser
Mar 6, 2026
Merged
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
a7284ce
build(app): add System.CommandLine v2 package dependency
arturcic 442a8f8
refactor(app): rename ArgumentParser to LegacyArgumentParser
arturcic 8bfb482
feat(app): add POSIX-style argument parser using System.CommandLine
arturcic 6bf3537
refactor(app): wire new parser via DI with env-var toggle
arturcic ea49c76
test(app): update ArgumentParserTests for POSIX-style syntax
arturcic c2f50c1
test(app): add LegacyArgumentParserTests and isolate with TestEnviron…
arturcic b22670c
test(app): update integration tests to use POSIX CLI syntax
arturcic 3eebf4c
docs(cli): update all documentation to POSIX --long-name syntax
arturcic 3a14f94
refactor(parser): Rename SystemCommandLineArgumentParser
arturcic 8997061
perf(parser): Optimize command-line argument parser initialization
arturcic 80e7a8a
refactor(gitversion): Adopt POSIX-style long arguments
arturcic bf91dae
feat(cli): Add toggle for legacy argument parser
arturcic 96d1a99
docs(breaking-changes): Document CLI and logging refactors
arturcic bca042c
fix(parser): Clarify -c and --commit argument mapping
arturcic 358aaf2
feat(cli): Introduce POSIX-style argument parsing and documentation
arturcic dd8f3f0
test(arguments): Update help writer test for legacy parser
arturcic 6f1a626
feat(cli): enhance argument descriptions and add help wrapping
arturcic 0576040
refactor(cli): Rename legacy argument help file
arturcic 2072fb8
refactor(cli): Delegate help and version handling to System.CommandLine
arturcic 19c724b
refactor(cli): Extract argument validation and reorganize parsing logic
arturcic c3e04fe
refactor(arguments): standardize working directory to absolute path
arturcic 3ab6e1e
docs(migration): Add v6 to v7 migration guide for CLI arguments
arturcic 4f39d5a
docs(cli): Recommend long-form arguments for scripts and documentation
arturcic 5cdc574
refactor(arguments): Use extension method for boolean string parsing
arturcic File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| { | ||
| "MD026": false, | ||
| "MD041": false | ||
| "MD041": false, | ||
| "MD013": false | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| --- | ||
| Title: Migration | ||
| Description: Technical reference documentation. | ||
| Order: 100 | ||
| --- | ||
| <p>@Html.Raw(Model.String(DocsKeys.Description))</p> | ||
|
|
||
| @Html.Partial("_ChildPages") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| --- | ||
| Order: 10 | ||
| Title: Migration v6 to v7 | ||
| Description: Migration guidance for upgrading from GitVersion v6 to GitVersion v7. | ||
| --- | ||
|
|
||
| This document summarizes the relevant breaking changes when migrating from GitVersion v6 to v7. | ||
|
|
||
| ## CLI Arguments - POSIX-style syntax | ||
|
|
||
| GitVersion now uses POSIX-style command-line arguments powered by System.CommandLine. | ||
|
|
||
| :::{.alert .alert-warning} | ||
| **Breaking change:** Legacy Windows-style (`/switch`) and legacy single-dash long-form (`-switch`) arguments are no longer accepted by default. | ||
|
|
||
| As a temporary migration aid, set `GITVERSION_USE_V6_ARGUMENT_PARSER=true` to restore legacy argument handling. This compatibility mode is temporary and will be removed in a future release. | ||
| ::: | ||
|
|
||
| ### What you need to change | ||
|
|
||
| 1. Replace old argument names with POSIX-style `--long-name` arguments. | ||
| 2. Prefer `--long-name` arguments for readability and maintainability. Supported short aliases (`-o`, `-v`, `-f`, `-c`, `-l`, `-d`, `-b`, `-u`, `-p`) remain available for interactive use. | ||
| 3. Update scripts that used `-c <commit>` to `--commit <commit>`. | ||
| 4. Optionally use `GITVERSION_REMOTE_USERNAME` and `GITVERSION_REMOTE_PASSWORD` instead of passing credentials on the command line. | ||
|
|
||
| ### Full argument mapping | ||
|
|
||
| | Old argument | New argument | Short alias | Env var alternative | | ||
| | ----------------------------- | -------------------------------- | ------------------------------ | ---------------------------- | | ||
| | `/targetpath <path>` | `--target-path <path>` | _(positional `path` argument)_ | | | ||
| | `/output <type>` | `--output <type>` | `-o` | | | ||
| | `/outputfile <path>` | `--output-file <path>` | | | | ||
| | `/showvariable <var>` | `--show-variable <var>` | `-v` | | | ||
| | `/format <format>` | `--format <format>` | `-f` | | | ||
| | `/config <path>` | `--config <path>` | `-c` | | | ||
| | `/showconfig` | `--show-config` | | | | ||
| | `/overrideconfig <k=v>` | `--override-config <k=v>` | | | | ||
| | `/nocache` | `--no-cache` | | | | ||
| | `/nofetch` | `--no-fetch` | | | | ||
| | `/nonormalize` | `--no-normalize` | | | | ||
| | `/allowshallow` | `--allow-shallow` | | | | ||
| | `/verbosity <level>` | `--verbosity <level>` | | | | ||
| | `/l <path>` | `--log-file <path>` | `-l` | | | ||
| | `/diag` | `--diagnose` | `-d` | | | ||
| | `/updateassemblyinfo [files]` | `--update-assembly-info [files]` | | | | ||
| | `/updateprojectfiles [files]` | `--update-project-files [files]` | | | | ||
| | `/ensureassemblyinfo` | `--ensure-assembly-info` | | | | ||
| | `/updatewixversionfile` | `--update-wix-version-file` | | | | ||
| | `/url <url>` | `--url <url>` | | | | ||
| | `/b <branch>` | `--branch <branch>` | `-b` | | | ||
| | `/u <username>` | `--username <username>` | `-u` | `GITVERSION_REMOTE_USERNAME` | | ||
| | `/p <password>` | `--password <password>` | `-p` | `GITVERSION_REMOTE_PASSWORD` | | ||
| | `/c <commit>` | `--commit <commit>` | _(no short alias)_ | | | ||
| | `/dynamicRepoLocation <path>` | `--dynamic-repo-location <path>` | | | | ||
|
|
||
| :::{.alert .alert-danger} | ||
| **Important:** `-c` now maps to `--config`. | ||
|
|
||
| If you previously used `-c <commit-id>`, you must replace it with `--commit <commit-id>`. | ||
| ::: | ||
|
|
||
| ### Example updates | ||
|
|
||
| ```bash | ||
| # Before | ||
| gitversion /output json /showvariable SemVer /config GitVersion.yml | ||
|
|
||
| # After | ||
| gitversion --output json --show-variable SemVer --config GitVersion.yml | ||
| ``` | ||
|
|
||
| ```bash | ||
| # Before | ||
| gitversion /url https://github.com/org/repo.git /b main /u user /p pass /c a1b2c3 | ||
|
|
||
| # After | ||
| gitversion --url https://github.com/org/repo.git --branch main --username user --password pass --commit a1b2c3 | ||
| ``` | ||
|
|
||
| For current command details and examples, see [CLI Arguments](/docs/usage/cli/arguments). | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.