-
Notifications
You must be signed in to change notification settings - Fork 53
/
structure.go
64 lines (57 loc) · 1.49 KB
/
structure.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
64
package components
type App struct {
Version string
Namespace
Subcommands []Namespace
}
func CreateApp(name, version, description string, commands []Command) App {
return App{
Version: version,
Namespace: Namespace{
Name: name,
Description: description,
Commands: commands,
},
}
}
func CreateEmbeddedApp(name string, commands []Command, namespaces ...Namespace) App {
app := App{
Namespace: Namespace{
Name: name,
Commands: commands,
},
}
app.Subcommands = append(app.Subcommands, namespaces...)
return app
}
type Namespace struct {
Name string
Description string
Category string
Commands []Command
}
type Command struct {
Name string
Description string
Category string
Aliases []string
UsageOptions *UsageOptions
Arguments []Argument
Flags []Flag
EnvVars []EnvVar
Action ActionFunc
SkipFlagParsing bool
Hidden bool
}
type UsageOptions struct {
// Special cases, each of these will be created as command usage option and the value appended as suffix for the command name.
Usage []string
// If true then the given usages will replace the auto generated usage. Otherwise the given usages will be appended to the auto generated usage.
ReplaceAutoGeneratedUsage bool
}
type PluginSignature struct {
Name string `json:"name,omitempty"`
Usage string `json:"usage,omitempty"`
// Only used internally in the CLI.
ExecutablePath string `json:"executablePath,omitempty"`
}