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

Built-in parameter --version conflicts with existing one #1530

Closed
sailro opened this issue Apr 25, 2024 · 9 comments · Fixed by #1531
Closed

Built-in parameter --version conflicts with existing one #1530

sailro opened this issue Apr 25, 2024 · 9 comments · Fixed by #1531
Labels
bug Something isn't working needs triage

Comments

@sailro
Copy link

sailro commented Apr 25, 2024

Information

  • OS: Windows
  • Version: Spectre.Console.Cli v0.49.0
  • Terminal: Windows Terminal / Oh My Posh

Describe the bug
Recent Spectre.Console.Cli versions fixed the issue with the new built-in --version parameter when running the application, but we can still spot this one when using --help. My application is using --version|-v for a dedicated usage for years, so I don't want to see nor use the new Prints version information in the help menu. Is there a way to remove this ? Thanks !

To Reproduce
You can use:
https://github.com/sailro/DependencyPath
https://www.nuget.org/packages/DependencyPath#readme-body-tab
with the following command dependency-path --help

Expected behavior
I don't want to see a conflicting --version parameter with my own.

Screenshots
image

Additional context
cc @FrankRay78 unfortunately, this simple little feature seems to be causing so many problems since its introduction.

Thanks !


Please upvote 👍 this issue if you are interested in it.

@sailro sailro added bug Something isn't working needs triage labels Apr 25, 2024
@github-project-automation github-project-automation bot moved this to Todo 🕑 in Spectre Console Apr 25, 2024
@patriksvensson
Copy link
Contributor

That’s unfortunate. We should make the ʼ-—versionʼ option completely opt-in and ensure it’s easy to override the behaviour if wanted.

I’m not super familiar with the changes that went into this specific addition, but I will take a look tonight and see if we can’t push a 0.49.1 version out that fixes this.

@sailro
Copy link
Author

sailro commented Apr 25, 2024

Thank you @patriksvensson , yes I fully agree. Making this opt-in would be great. No risk to break existing applications.

@github-project-automation github-project-automation bot moved this from Todo 🕑 to Done 🚀 in Spectre Console Apr 25, 2024
@patriksvensson
Copy link
Contributor

There should be a version 0.49.1 out now. Let me know if that version solved this issue; otherwise, just reopen it.

@sailro
Copy link
Author

sailro commented Apr 26, 2024

Yes, I confirm this is working properly with 0.49.1. Thank you again for quickly addressing this issue !

@Kampfmoehre
Copy link

Kampfmoehre commented Apr 26, 2024

Do we have to enable the built-in version feature now and how do we do it? With 0.49.1 the --version switch does no longer work, instead it prints out

Error: Unexpected option 'version'.

       --version
       ^^^^^^^^^ Did you forget the command?

@patriksvensson
Copy link
Contributor

Use config.UseAssemblyInformationalVersion() to get auto versioning.

@samuel-lucas6
Copy link

config.SetApplicationVersion() and config.UseAssemblyInformationalVersion() didn't seem to work when I was testing 0.49.1. -v|--version didn't skip the Validate method like -h|--help, so I just got an error.

Then on 0.48.0, -v|--version prints a hex string after the version number on macOS:

$ application -v
1.0.0+6bc659b6988fe4317f8ce82c78f45b074606163f

I can't test whether this has been fixed on 0.49.1. If it hasn't, that should obviously be a separate issue.

@patriksvensson
Copy link
Contributor

@samuel-lucas6 Could you provide a minimal reproducable example for this?

@samuel-lucas6
Copy link

@samuel-lucas6 Could you provide a minimal reproducable example for this?

Sorry for not providing much detail. If you have a mandatory string CommandOption and do the following in Validate(CommandContext context, Settings settings):

if (string.IsNullOrWhiteSpace(settings.StringOption)) {
    return ValidationResult.Error("string option must be specified.");
}

Then -v|--version doesn't work because you get the validation error, whereas -h|--help does because validation is skipped. This wasn't a problem in 0.48.0. If you'd like a more concrete example, this is the program I'm working on. Hope that helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs triage
Projects
Status: Done 🚀
Development

Successfully merging a pull request may close this issue.

4 participants