1// Copyright 2022 The Bazel Authors. All rights reserved. 2// 3// Licensed under the Apache License, Version 2.0 (the "License"); 4// you may not use this file except in compliance with the License. 5// You may obtain a copy of the License at 6// 7// http://www.apache.org/licenses/LICENSE-2.0 8// 9// Unless required by applicable law or agreed to in writing, software 10// distributed under the License is distributed on an "AS IS" BASIS, 11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12// See the License for the specific language governing permissions and 13// limitations under the License. 14 15package cmd 16 17import ( 18 "os" 19 20 "github.com/spf13/cobra" 21) 22 23// rootCmd represents the base command when called without any subcommands 24var rootCmd = &cobra.Command{ 25 Use: "go-code-tutorial", 26 Short: "A brief description of your application", 27 Long: `A longer description that spans multiple lines and likely contains 28examples and usage of using your application. For example: 29 30Cobra is a CLI library for Go that empowers applications. 31This application is a tool to generate the needed files 32to quickly create a Cobra application.`, 33 // Uncomment the following line if your bare application 34 // has an action associated with it: 35 // Run: func(cmd *cobra.Command, args []string) { }, 36} 37 38// Execute adds all child commands to the root command and sets flags appropriately. 39// This is called by main.main(). It only needs to happen once to the rootCmd. 40func Execute() { 41 err := rootCmd.Execute() 42 if err != nil { 43 os.Exit(1) 44 } 45} 46 47func init() { 48 rootCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle") 49} 50