-
Notifications
You must be signed in to change notification settings - Fork 0
/
cli.go
42 lines (34 loc) · 908 Bytes
/
cli.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
package main
import (
"fmt"
"github.com/spf13/cobra"
)
const version = "1.0.1"
var (
// Flags
verbose bool
rootCmd = &cobra.Command{
Use: "yester",
Short: "A YAML based API test runner",
Long: `Yester is a YAML based API test runner.
For full documentation, reference https://github.com/serdnad/yester`,
Run: func(cmd *cobra.Command, args []string) {
// if version flag set, print version and return
printVersion, _ := cmd.PersistentFlags().GetBool("version")
if printVersion {
fmt.Printf("yester v%s\n", version)
return
}
// parse other flags
verbose, _ = cmd.PersistentFlags().GetBool("verbose")
run()
},
}
)
func main() {
rootCmd.Execute()
}
func init() {
rootCmd.PersistentFlags().BoolP("version", "v", false, "print the current version of yester")
rootCmd.PersistentFlags().BoolP("verbose", "V", false, "print more details about test results")
}