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 a version command #16

Open
johncblandii opened this issue Apr 21, 2020 · 7 comments
Open

Add a version command #16

johncblandii opened this issue Apr 21, 2020 · 7 comments

Comments

@johncblandii
Copy link
Contributor

Feature

Add a command to see the version of the CLI.

> variant version
X.Y.Z
@mumoshu
Copy link
Owner

mumoshu commented Apr 22, 2020

@johncblandii It's the version number of the Variant itself, not that of your own command, right? If so, it makes sense!

@osterman
Copy link

Yep, some way to know what version is installed

@johncblandii
Copy link
Contributor Author

Yep...exactly. We would do our own version management.

@osterman
Copy link

@mumoshu I know you're concerned about polluting the arg space with variant commands and options. Maybe time to consider a "reserved" prefix (e.g. --variant-version, --variant-help, etc)?

@mumoshu
Copy link
Owner

mumoshu commented Apr 22, 2020

@osterman Thanks!

But no. In Variant 2, variant run or ./yourshim is used as the entry point for all the user-defined commands and flags.

So the user-defined one would be just variant run version or /yourshim version, where the variant's reserved one would be variant version.

In case you need to include the version number of Varaint in the output of variant run version, it would be better to expose it via a builtin variable like context.variantver.

@osterman
Copy link

thanks @mumoshu - makes sense to me now

@Nuru
Copy link

Nuru commented Apr 26, 2021

In case you need to include the version number of Varaint in the output of variant run version, it would be better to expose it via a builtin variable like context.variantver.

Please expand more on this idea of context.variantver or better yet, fully document context (See #50).

I would like to be able to display both the version of Variant my command is using and the version of my command. One possible solution:

  • In package main declare string variables version and variantversion
  • At build time, set variantversion to the version of Variant using whatever mechanism you want, so long as variant export preserves the variantversion value
  • Add a variant version command that outputs main.variantversion
  • Expose in context or via some function, both version and variantversion. If version is unset or empty, replace it with variantversion

This would (a) allow you to have a variant version command as requested, and (b) allow me to set a command version through the linker via

go build -ldflags "-X main.version=${MY_COMMAND_VERSION}"

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

No branches or pull requests

4 participants