-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
35 lines (32 loc) · 836 Bytes
/
main.go
File metadata and controls
35 lines (32 loc) · 836 Bytes
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
// Copyright © 2017 NAME HERE <EMAIL ADDRESS>
//
// OO design for Command.go just like cobra
package main
import (
"fmt"
cmd "github.com/pmlpml/agenda/cmd"
)
func main() {
//cmd.Execute()
var RootCmd = &cmd.Command{
Use: "test",
Short: "A brief description of your application",
Long: "A longer description",
}
RootCmd.SetOptions = func(c *cmd.Command) error {
fmt.Println("Set Options here ...")
c.Flags().StringP("user", "u", "Anonymous", "Help message for username")
return nil
}
RootCmd.Parse = func(c *cmd.Command) error {
fmt.Println("Parse here ...")
c.Flags().Parse(cmd.Args)
return nil
}
RootCmd.Run = func(c *cmd.Command, a []string) {
fmt.Println("Do comamnd here ...")
username, _ := c.Flags().GetString("user")
fmt.Println("myCommand called by " + username)
}
RootCmd.Execute()
}