Skip to content
This repository was archived by the owner on Jan 16, 2021. It is now read-only.

Commit a1eaa19

Browse files
committed
[update] do not check version support at update
currently we check and report unsupported versions even during `parse update` this diff checks against that. since operation is not needed
1 parent f654bbb commit a1eaa19

File tree

2 files changed

+17
-12
lines changed

2 files changed

+17
-12
lines changed

commands.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
"github.com/spf13/cobra"
99
)
1010

11-
func parseRootCmd(e *env) *cobra.Command {
11+
func parseRootCmd(e *env) ([]string, *cobra.Command) {
1212
c := &cobra.Command{
1313
Use: "parse",
1414
Long: fmt.Sprintf(
@@ -45,7 +45,7 @@ http://parse.com`,
4545
c.AddCommand(newVersionCmd(e))
4646

4747
if len(os.Args) <= 1 {
48-
return c
48+
return nil, c
4949
}
5050

5151
commands := []string{"help"}
@@ -61,5 +61,5 @@ http://parse.com`,
6161
}
6262
c.SetArgs(args)
6363

64-
return c
64+
return args, c
6565
}

main.go

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -100,19 +100,24 @@ func main() {
100100
}
101101
e.ParseAPIClient = apiClient
102102

103-
var rootCmd *cobra.Command
103+
var (
104+
rootCmd *cobra.Command
105+
command []string
106+
)
104107
switch e.Type {
105108
case legacyParseFormat, parseFormat:
106-
rootCmd = parseRootCmd(&e)
109+
command, rootCmd = parseRootCmd(&e)
107110
}
108111

109-
message, err := checkIfSupported(&e, version, os.Args[1:]...)
110-
if err != nil {
111-
fmt.Fprintln(e.Err, err)
112-
os.Exit(1)
113-
}
114-
if message != "" {
115-
fmt.Fprintln(e.Err, message)
112+
if len(command) == 0 || command[0] != "update" {
113+
message, err := checkIfSupported(&e, version, command...)
114+
if err != nil {
115+
fmt.Fprintln(e.Err, err)
116+
os.Exit(1)
117+
}
118+
if message != "" {
119+
fmt.Fprintln(e.Err, message)
120+
}
116121
}
117122

118123
if err := rootCmd.Execute(); err != nil {

0 commit comments

Comments
 (0)