gitee.com/mirrors/gauge@v1.0.6/cmd/init.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 "fmt" 22 23 "github.com/getgauge/gauge/projectInit" 24 "github.com/spf13/cobra" 25 ) 26 27 var ( 28 initCmd = &cobra.Command{ 29 Use: "init [flags] <template>", 30 Short: "Initialize project structure in the current directory", 31 Long: `Initialize project structure in the current directory.`, 32 Example: " gauge init java", 33 Run: func(cmd *cobra.Command, args []string) { 34 if templates { 35 projectInit.ListTemplates() 36 return 37 } 38 if len(args) < 1 { 39 exit(fmt.Errorf("Missing argument <template name>. To see all the templates, run 'gauge list-templates'"), cmd.UsageString()) 40 } 41 projectInit.InitializeProject(args[0], machineReadable) 42 }, 43 DisableAutoGenTag: true, 44 } 45 templates bool 46 ) 47 48 func init() { 49 GaugeCmd.AddCommand(initCmd) 50 initCmd.Flags().BoolVarP(&templates, "templates", "t", false, "Lists all available templates") 51 }