Skip to content

Instantly share code, notes, and snippets.

@mahdyadi
Created March 8, 2020 21:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mahdyadi/67d394238b5075aa75e0df1c5accfb7a to your computer and use it in GitHub Desktop.
Save mahdyadi/67d394238b5075aa75e0df1c5accfb7a to your computer and use it in GitHub Desktop.
package cmd
import (
"fmt"
"github.com/spf13/cobra"
)
var name string
var helloCmd = &cobra.Command{
Use: "hello",
Short: "Say hello to anyone!",
Long: "Say hello to the world & anyone!",
Run: func(cmd *cobra.Command, args []string) {
fmt.Printf("Hello, %s!\n", name)
},
}
func init() {
helloCmd.Flags().StringVarP(
&name,
"name",
"n",
"World",
"The name you want to say hello to!",
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment