-
Notifications
You must be signed in to change notification settings - Fork 151
/
custom_cli.go
62 lines (56 loc) · 1.28 KB
/
custom_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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package test
import (
"context"
"reflect"
"github.com/scaleway/scaleway-cli/v2/internal/core"
)
func GetCustomCommands() *core.Commands {
return core.NewCommands(
CustomTestRoot(),
CustomTestAnonymousFields(),
)
}
func CustomTestRoot() *core.Command {
return &core.Command{
Namespace: "test",
Short: "Custom tests",
Long: "Ucstom tests.",
}
}
func CustomTestAnonymousFields() *core.Command {
type testAnonymousFields struct {
FieldA string // this field is overridden by testAnonymousFieldsCustom.FieldA
FieldB string
}
type testAnonymousFieldsCustom struct {
*testAnonymousFields
FieldC string
FieldA string
}
return &core.Command{
Short: `Test Anonymous Fields`,
Long: `Test Anonymous Fields.`,
Namespace: "test",
Resource: "anonymous-fields",
ArgsType: reflect.TypeOf(testAnonymousFieldsCustom{}),
ArgSpecs: core.ArgSpecs{
{
Name: "field-b",
Short: `Field B`,
},
{
Name: "field-c",
Short: `Field C`,
},
// Because testAnonymousFields.FieldA is overridden by testAnonymousFieldsCustom.FieldA
// the usage for FieldA should be at the end
{
Name: "field-a",
Short: `Field A`,
},
},
Run: func(_ context.Context, _ interface{}) (i interface{}, e error) {
return "", nil
},
}
}