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 --version and --help flags to executables #97

Closed
wants to merge 6 commits into from

Conversation

RKinsey
Copy link
Contributor

@RKinsey RKinsey commented Jan 28, 2020

Closes #74 , Closes #101
This patch adds flags for access to the usage message and the version tag/hash as requested in #74 and #57, respectively.

age and age-keygen with the --help or -h flag will print their usage message and exit, and age will also print usage when no flags or arguments are passed. Per #22, I didn't add age help.
age-keygen now has a usage message.

-v and (Removed, see below) --version work for both age and age-keygen, and will print the most recent git info at time of compilation. There are two build scripts (bash and Powershell) that grab the most recent tag and current short hash, and uses -ldflags to pass them to main.version and main.commit (named for compatibility with goreleaser defaults). Current format is

Version: [most recent tag]
Hash: [shorthash] 

and
Version: [most recent tag] when on a tagged commit or the --release flag is passed to the script.
I also updated the Homebrew formula for this, but it doesn't currently have an effect

@RKinsey RKinsey changed the title Add version and help printing Add --version and --help flags to executables Jan 28, 2020
@wgslr
Copy link

wgslr commented Jan 28, 2020

I'm glad to see you implemented my proposal. Just one note: I would be wary of using the -v flag for --version, as it is often used for --verbose and I could image age adding such flag in the future. I suggest either using -V or not providing a short flag at all, as the version invocation is done rarely and does not need to be particularly compact.

@RKinsey
Copy link
Contributor Author

RKinsey commented Jan 28, 2020

Good point, removed -v

@alerque
Copy link
Contributor

alerque commented Feb 13, 2020

@RKinsey I think you can also add Closes #101 to this issue description.

@RKinsey
Copy link
Contributor Author

RKinsey commented Feb 18, 2020

Got it

@Fastidious
Copy link

Would be great if this PR could be accepted. What say you, @FiloSottile? :-)

@brad2014
Copy link

Just a thought: There are two relevant version strings related to the age app: the release version of the code (currently "v1.0.0-beta2") and the version(s) of the supported file spec (currently "v1", but a later release might support multiple file specs).

Do you want to consider wording the age --help and the age --version output to distinguish between these two uses of the word version? Maybe:

% age --version 
Release version: 1.0.0-beta2
Age spec version: v1

@shepting
Copy link

I'd love to see this land! Any updates @RKinsey

FiloSottile added a commit that referenced this pull request Jan 2, 2021
FiloSottile added a commit that referenced this pull request Jan 3, 2021
@FiloSottile
Copy link
Owner

Most users will eventually use go install filippo.io/age/cmd/...@latest (which from Go 1.16 embeds the version) or Homebrew or a package manager, so I took a slightly simpler path in #173. Thank you!

@brad2014 that's a good point, but we don't plan to ever drop support for older versions of the spec, so for now I think it's fine not to expose it.

@ank-everstake
Copy link

I think it may be better to expose info for debug purposes.
User can open age-encrypted file on another machine with different age-binary.
So basically if we hide it we don't have any option to know what binary the user has.
You can compile by yourself, get pre-built binaries or get them through pacman AUR (in Arch).
Please consider to add the version back. Thanks.

CC @dd-everstake

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

Successfully merging this pull request may close these issues.

UX: What version of age am I running? UX: Show usage on naked command
8 participants