-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Support short and json formats for version cmd #1315
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
Conversation
a43f412
to
c23afbc
Compare
|
c23afbc
to
f7417e6
Compare
@@ -234,6 +234,7 @@ func (e *Executor) getConfigForCommandLine() (*config.Config, error) { | |||
// Use another config variable here, not e.cfg, to not | |||
// affect main parsing by this parsing of only config option. | |||
initFlagSet(fs, &cfg, e.DBManager, false) | |||
initVersionFlagSet(fs, &cfg) |
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.
can you explain rationale behind this line ?
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.
Sure. We need to refactor this code. Now the executer uses same set of the flags for all commands, and when I defined the flag for version command only it's failed with an error with unknown --format
arg, here:
golangci-lint/pkg/commands/run.go
Line 244 in f7417e6
fs.Usage = func() {} // otherwise help text will be printed twice |
This is kind of workaround, I think we need to have a hard refactoring of all this code and do not mix the flags for run
command with other command, ideally every command must have independent sets of flags
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.
Oh I see 👍
@@ -539,6 +543,7 @@ type Config struct { | |||
Linters Linters | |||
Issues Issues | |||
Severity Severity | |||
Version Version |
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 this one will come in .golangci.yaml file as well ?
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.
yes, it does.
20-08-18 10:28 % ./golangci-lint version
golangci-lint has version (devel) built from (unknown, mod sum: "") on (unknown)
20-08-18 10:28 % git diff
diff --git a/.golangci.yml b/.golangci.yml
index 5e9e1e7..fa899f6 100644
--- a/.golangci.yml
+++ b/.golangci.yml
@@ -146,3 +146,6 @@ service:
golangci-lint-version: 1.23.x # use the fixed version to not introduce new linters unexpectedly
prepare:
- echo "here I can run custom commands, but no preparation needed for this repo"
+
+version:
+ format: json
20-08-18 10:28 % ./golangci-lint version
{"version":"(devel)","commit":"(unknown, mod sum: \"\")","date":"(unknown)"}
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.
My original concern was that if this should be part of configuration file. Then, I think it's not much a big deal as long as we don't break declarative understanding of config file (e.g. it will be very weird to specify actual version in config file).
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.
oh no, we don't specify a version in the config file, just the output format
f7417e6
to
ed2ae34
Compare
Closes #1314
Support printing the version I different formats: