Build: cobra 脚手架引入
This commit is contained in:
+36
@@ -0,0 +1,36 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
// Root Command
|
||||
var rootCmd = &cobra.Command{
|
||||
Use: "wonder",
|
||||
Short: "Here we go",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
fmt.Println("Here we go")
|
||||
},
|
||||
}
|
||||
|
||||
// Echo Command
|
||||
var echoCmd = &cobra.Command{
|
||||
Use: "girlfriend",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
fmt.Println("I love my girlfriend")
|
||||
},
|
||||
}
|
||||
|
||||
// main
|
||||
func main() {
|
||||
// Add
|
||||
rootCmd.AddCommand(echoCmd)
|
||||
// Exec
|
||||
if err := rootCmd.Execute(); err != nil {
|
||||
fmt.Fprintln(os.Stderr, err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user