-
Notifications
You must be signed in to change notification settings - Fork 0
/
moo.go
46 lines (35 loc) · 860 Bytes
/
moo.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/*
Copyright © 2022 Diego Morales <dgmorales@gmail.com>
*/
package cmd
import (
"fmt"
"strings"
cowsay "github.com/Code-Hex/Neo-cowsay/v2"
"github.com/dgmorales/go-cli-selfupdate/start"
"github.com/spf13/cobra"
)
// mooCmd represents the moo command
var mooCmd = &cobra.Command{
Use: "moo",
Short: "Cow-Echo something back to console",
Long: `I'm a dummy cmd in a test app with other purposes.
Cowsaying is fun. What's more to say?
`,
Run: func(cmd *cobra.Command, args []string) {
// we need no state at all on this command
start.ForLocalUse(flagDebug)
say := "moo"
if len(args) > 0 {
say = strings.Join(args, " ")
}
mooSay, err := cowsay.Say(say)
if err != nil {
panic(err) // I'm a dummy command, I can allow myself to panic occasionally
}
fmt.Println(mooSay)
},
}
func init() {
rootCmd.AddCommand(mooCmd)
}