gitee.com/mirrors/gauge@v1.0.6/cmd/install.go (about) 1 // Copyright 2015 ThoughtWorks, Inc. 2 3 // This file is part of Gauge. 4 5 // Gauge is free software: you can redistribute it and/or modify 6 // it under the terms of the GNU General Public License as published by 7 // the Free Software Foundation, either version 3 of the License, or 8 // (at your option) any later version. 9 10 // Gauge is distributed in the hope that it will be useful, 11 // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 // GNU General Public License for more details. 14 15 // You should have received a copy of the GNU General Public License 16 // along with Gauge. If not, see <http://www.gnu.org/licenses/>. 17 18 package cmd 19 20 import ( 21 "github.com/getgauge/gauge/logger" 22 "github.com/getgauge/gauge/plugin/install" 23 "github.com/spf13/cobra" 24 ) 25 26 var ( 27 installCmd = &cobra.Command{ 28 Use: "install [flags] [plugin]", 29 Short: "Download and install plugin(s)", 30 Long: `Download and install specified plugin or all plugins in the project's 'manifest.json' file.`, 31 Example: ` gauge install 32 gauge install java 33 gauge install java -f gauge-java-0.6.3-darwin.x86_64.zip`, 34 Run: func(cmd *cobra.Command, args []string) { 35 if len(args) < 1 { 36 install.AllPlugins(machineReadable, false) 37 return 38 } 39 if zip != "" { 40 install.HandleInstallResult(install.InstallPluginFromZipFile(zip, args[0]), args[0], true) 41 } else { 42 install.HandleInstallResult(install.Plugin(args[0], pVersion, machineReadable), args[0], true) 43 } 44 if err := install.AddPluginToProject(args[0]); err != nil { 45 logger.Fatalf(true, "Failed to add plugin %s to project : %s\n", args[0], err.Error()) 46 } 47 }, 48 DisableAutoGenTag: true, 49 } 50 zip string 51 pVersion string 52 ) 53 54 func init() { 55 GaugeCmd.AddCommand(installCmd) 56 installCmd.Flags().StringVarP(&zip, "file", "f", "", "Installs the plugin from zip file") 57 installCmd.Flags().StringVarP(&pVersion, "version", "v", "", "Version of plugin to be installed") 58 }