-
Notifications
You must be signed in to change notification settings - Fork 0
/
hack.go
43 lines (33 loc) · 907 Bytes
/
hack.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
package commands
import (
"fmt"
"github.com/avanibbles/flowflow/pkg"
"github.com/avanibbles/flowflow/pkg/client/hack"
"github.com/avanibbles/flowflow/pkg/config"
"github.com/spf13/cobra"
)
var (
errorCode int
hackCommand = &cobra.Command{Use: "hack", Short: "dev testing"}
errorCodeTest = &cobra.Command{
Use: "errors",
Short: "test errors",
Run: func(cmd *cobra.Command, args []string) {
conf, err := config.LoadConfigFromViper()
cobra.CheckErr(err)
api, err := pkg.NewApiClient(conf)
cobra.CheckErr(err)
req := hack.NewGetAPIV1HackErrCodeParams()
req.SetCode(int64(errorCode))
resp, err := api.Hack.GetAPIV1HackErrCode(req)
if err != nil {
fmt.Println(err)
} else {
fmt.Println(resp)
}
}}
)
func init() {
errorCodeTest.Flags().IntVarP(&errorCode, "error", "e", 200, "the error code to produce")
hackCommand.AddCommand(errorCodeTest)
}