Support short and json formats for version cmd#1315
Conversation
a43f412 to
c23afbc
Compare
|
|
c23afbc to
f7417e6
Compare
| // 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.
can you explain rationale behind this line ?
There was a problem hiding this comment.
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
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
| Linters Linters | ||
| Issues Issues | ||
| Severity Severity | ||
| Version Version |
There was a problem hiding this comment.
so this one will come in .golangci.yaml file as well ?
There was a problem hiding this comment.
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.
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.
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: