-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
63 lines (57 loc) · 1.35 KB
/
main.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package main
import (
"context"
"fmt"
"github.com/urfave/cli/v3"
"github.com/vearne/autotest/internal/command"
slog "github.com/vearne/simplelog"
"log"
"os"
)
const (
version = "v0.1.7"
)
func main() {
slog.SetLevel(slog.InfoLevel)
cli.VersionPrinter = func(cmd *cli.Command) {
fmt.Printf("version=%s\n", cmd.Root().Version)
}
cmd := &cli.Command{
Name: "autotest",
Version: version,
Usage: "automate test",
Authors: []any{"vearne"},
Copyright: "2024 vearne",
Commands: []*cli.Command{
{
Name: "test",
Flags: []cli.Flag{
&cli.StringFlag{Name: "config-file", Aliases: []string{"c"}},
},
Usage: "validate configuration files",
Action: command.ValidateConfig,
},
{
Name: "run",
Flags: []cli.Flag{
&cli.StringFlag{Name: "config-file", Aliases: []string{"c"}},
&cli.StringFlag{Name: "env-file", Aliases: []string{"e"}},
},
Usage: "run all test cases",
Action: command.RunTestCases,
},
{
Name: "extract",
Flags: []cli.Flag{
&cli.StringFlag{Name: "xpath", Aliases: []string{"x"}},
&cli.StringFlag{Name: "json", Aliases: []string{"j"}},
},
Usage: "try to extract data corresponding to xpath from json string",
Action: command.ExtractXpath,
},
},
}
if err := cmd.Run(context.Background(), os.Args); err != nil {
log.Fatal(err)
}
}