-
Notifications
You must be signed in to change notification settings - Fork 338
/
update.go
47 lines (42 loc) · 1.25 KB
/
update.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/*----------------------------------------------------------------
* Copyright (c) ThoughtWorks, Inc.
* Licensed under the Apache License, Version 2.0
* See LICENSE in the project root for license information.
*----------------------------------------------------------------*/
package cmd
import (
"fmt"
"github.com/getgauge/gauge/plugin/install"
"github.com/spf13/cobra"
)
var (
updateCmd = &cobra.Command{
Use: "update [flags] <plugin>",
Short: "Updates a plugin",
Long: `Updates a plugin.`,
Example: ` gauge update java
gauge update -a
gauge update -c`,
Run: func(cmd *cobra.Command, args []string) {
if all {
install.UpdatePlugins(machineReadable)
return
} else if check {
install.PrintUpdateInfoWithDetails()
return
}
if len(args) < 1 {
exit(fmt.Errorf("missing argument <plugin name>"), cmd.UsageString())
}
install.HandleUpdateResult(install.Plugin(args[0], pVersion, machineReadable), args[0], true)
},
DisableAutoGenTag: true,
}
all bool
check bool
)
func init() {
GaugeCmd.AddCommand(updateCmd)
updateCmd.Flags().BoolVarP(&all, "all", "a", false, "Updates all the installed Gauge plugins")
updateCmd.Flags().BoolVarP(&check, "check", "c", false, "Checks for Gauge and plugins updates")
}