@cryptotaxi247 / kubo / commits / 6f219e0d8

fix(flag/version): flag `all` should have a higher priority

License: MIT Signed-off-by: chenminjian <727180553@qq.com>

chenminjian committed Nov 2, 2018 at 19:23 UTC 6f219e0d8f9c3b29627dada41fb30a0e4580ddb9
1 file changed +12 -12
core/commands/version.go
+12 -12
@@ -50,24 +50,12 @@ var VersionCmd = &cmds.Command{
50 },
51 Encoders: cmds.EncoderMap{
52 cmds.Text: cmds.MakeTypedEncoder(func(req *cmds.Request, w io.Writer, version *VersionOutput) error {
53 - repo, _ := req.Options[versionRepoOptionName].(bool)
54 - if repo {
55 - fmt.Fprintln(w, version.Repo)
56 - return nil
57 - }
58 -
53 commit, _ := req.Options[versionCommitOptionName].(bool)
54 commitTxt := ""
55 if commit {
56 commitTxt = "-" + version.Commit
57 }
58
65 - number, _ := req.Options[versionNumberOptionName].(bool)
66 - if number {
67 - fmt.Fprintln(w, version.Version+commitTxt)
68 - return nil
69 - }
70 -
59 all, _ := req.Options[versionAllOptionName].(bool)
60 if all {
61 out := fmt.Sprintf("go-ipfs version: %s-%s\n"+
@@ -77,6 +65,18 @@ var VersionCmd = &cmds.Command{
65 return nil
66 }
67
68 + repo, _ := req.Options[versionRepoOptionName].(bool)
69 + if repo {
70 + fmt.Fprintln(w, version.Repo)
71 + return nil
72 + }
73 +
74 + number, _ := req.Options[versionNumberOptionName].(bool)
75 + if number {
76 + fmt.Fprintln(w, version.Version+commitTxt)
77 + return nil
78 + }
79 +
80 fmt.Fprint(w, fmt.Sprintf("ipfs version %s%s\n", version.Version, commitTxt))
81 return nil
82 }),