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