forked from gingteam/ddoser
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrootCommand.go
46 lines (36 loc) · 883 Bytes
/
rootCommand.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
package main
import (
"fmt"
"github.com/labstack/gommon/color"
"github.com/mkideal/cli"
)
type appT struct {
Name string
Version string
}
var app = appT{
"Go DDoser",
"v1.0.0",
}
func sprintHeader() string {
return fmt.Sprintf("%s version %s", color.Green(app.Name), color.Yellow(app.Version))
}
func printHeader() {
fmt.Print(sprintHeader() + "\n\n")
}
type rootT struct {
cli.Helper
}
var rootCommand = &cli.Command{
Desc: sprintHeader(),
// Argv is a factory function of argument object
// ctx.Argv() is if Command.Argv == nil or Command.Argv() is nil
Argv: func() interface{} { return new(rootT) },
Fn: func(ctx *cli.Context) error {
printHeader()
fmt.Print("Usage: go-ddoser <command>\n")
fmt.Printf("More information on usage with %s flag.\n", color.Yellow("--help"))
fmt.Printf("Backed by %s\n", color.Green("GingTeam"))
return nil
},
}