Created
March 8, 2020 21:40
-
-
Save mahdyadi/67d394238b5075aa75e0df1c5accfb7a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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