github.com/azunymous/cdx@v0.0.0-20201122180449-fbb46cc4d252/commands/options/app.go (about) 1 package options 2 3 import ( 4 "github.com/spf13/cobra" 5 ) 6 7 // App struct contains options regarding the application 8 type App struct { 9 Name string 10 } 11 12 func AddNameArg(cmd *cobra.Command, r *App) { 13 cmd.PersistentFlags().StringVarP(&r.Name, "name", "n", "", "Application or module name") 14 must(cmd.MarkPersistentFlagRequired("name")) 15 } 16 17 func must(err error) { 18 if err != nil { 19 panic(err) 20 } 21 }