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
Rework cobra CLI #41
Rework cobra CLI #41
Conversation
* Moved the CLI into cmd package. * Broke out each subcommand into own file. * Created a version subcommand, which allows the binary to be built with version information when passed the following LDFLAGS. LDFLAGS := -s -w \ -X 'main.version=$(VERSION)' -X 'main.buildHash=$(GITCOMMIT)' -X 'main.buildDate=$(BUILDDATE)'
Also added a sexy command banner lol
|
Since the CLI imports gcw the vendor/ directory should live at the base of the repo. This also brings the project in line with most other go projects. Updated Makefile and gitignore to preserve functionality.
4bda0ed
to
5d68bd0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not approving yet only due to the question about library vs. CLI tool dependencies (see inline)
cmd/root.go
Outdated
.-----. | |--. .--.--.--. | ||
| _ | | | | | | | | ||
|___ | |__|__| |________| | ||
|_____| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lol, this makes me think of someone giving someone else the middle finger.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lolol
cmd/version.go
Outdated
` | ||
|
||
// versionCmd represents the version command | ||
var versionCmd = &cobra.Command{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool. I'd wanted to do something like this. Thanks for adding it! :)
vendor/vendor.json
Outdated
@@ -21,5 +21,5 @@ | |||
"revisionTime": "2017-05-08T18:43:26Z" | |||
} | |||
], | |||
"rootPath": "github.com/jaypipes/ghw/ghwc" | |||
"rootPath": "github.com/jaypipes/ghw" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, the reason I had the ghwc/vendor folder was that I did not want to make cobra a dependency for the ghw library itself. I wanted to have as few (or no) dependencies for the importable library as possible. Is there a way to indicate that the dependency is only for the ghwc example client tool and not the library itself?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I seee. Now I understand what ghwc was for.
This reverts commit 5d68bd0.
This should allow the CLI to remain using vendored packages, while keeping dependencies as minimal as possible with the importable package.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fantastico. :)
Moved the CLI into cmd package.
Broke out each subcommand into own file.
Created a version subcommand, which allows the binary to be built
with version information when passed the following LDFLAGS.
LDFLAGS := -s -w
-X 'main.version=$(VERSION)'
-X 'main.buildHash=$(GITCOMMIT)'
-X 'main.buildDate=$(BUILDDATE)'