caicloud / nirvana

Golang Restful API Framework for Productivity
https://caicloud.github.io/nirvana/
Apache License 2.0
520 stars 105 forks source link

feat(cmd): add version command #373

Closed knight42 closed 3 years ago

knight42 commented 3 years ago

What this PR does / why we need it:

Add command nirvana version, so that users are able to know which version of nirvana they are using.

Which issue(s) this PR is related to (optional, link to 3rd issue(s)):

Fixes #

Reference to #

Special notes for your reviewer:

/cc @iawia002 @gaocegege

Release note:

cmd: add command `nirvana version`
caicloud-bot commented 3 years ago

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: To fully approve this pull request, please assign additional approvers. We suggest the following additional approver: kdada

Assign the PR to them by writing /assign @kdada in a comment when ready.

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files: - **[OWNERS](https://github.com/caicloud/nirvana/blob/master/OWNERS)** Approvers can indicate their approval by writing `/approve` in a comment Approvers can cancel approval by writing `/approve cancel` in a comment
iawia002 commented 3 years ago

This is probably not working, we normally install nirvana by go get command and we never publish any binary file. Maybe we can hardcode the version into the help message.

knight42 commented 3 years ago

@iawia002 I think we could probably build the binary on travis and upload the assets to GitHub automatically.

iawia002 commented 3 years ago

However, it is easier and more convenient for users to install with go get, so perhaps hardcode the version information would be a more general and easy solution.

xpofei commented 3 years ago

This way of printing version is ok. However you still should consider the output of 'nirvana version' when using manual 'go build'. In this case, it is recommended to print prompt statements such as "please use make tool to build in order to use version conmmand" instead of print a raw "v0.0.0-master+$Format:%h$"

knight42 commented 3 years ago

/close in favor of #376