-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathspec.go
104 lines (96 loc) · 3.25 KB
/
spec.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
package cli
// Spec is implemented by the generated by the `cli` code generator.
type Spec interface {
Cmd() *Cmd
Run()
}
// Cmd holds metadata related to a CLI command.
//
// Usually generated by the `cli` code generator.
type Cmd struct {
// RawName is the raw, unprocessed name of the function.
RawName string
// RawDoc is the raw, unprocessed doc string attached to the function.
RawDoc string
// Args describes metadata about the function arguments.
Args []*Arg
// Opts describes metadata about the function options
// (the `opt` argument, by convention).
Opts []*Opt
// The fields below are normally set by Enrich.
// Name is the command name,
// normally determined by parsing the raw function name and/or doc.
Name string
// Path is the path to this subcommand,
// normally determined by parsing the raw function name and/or docs.
Path []string
// Doc is the function doc after processing,
// where annotations such as "Deprecated" and "Hidden" are removed.
Doc string
// Synopsis is a short description of the command.
Synopsis string
// Example describes an example of how to use the command.
Example string
// Deprecated marks this command as deprecated and contains
// a message describing why.
Deprecated string
// Hidden marks this command as hidden.
Hidden bool
// Aliases contains aliases for this command.
Aliases []string
}
// Opt holds metadata related to an option of a Cmd.
//
// Usually generated by the `cli` code generator.
type Opt struct {
// Key is the path of struct fields names from the root to this option.
// e.g. ["Server", "TLS", "KeyPath"]
Key []string
// RawDoc is the raw, unprocessed doc string attached to this field.
RawDoc string
// The fields below are normally set by Enrich.
// Doc is the field doc after processing,
// where annotations such as "Deprecated" and "Hidden" are removed.
Doc string
// Synopsis is a short description of this option.
Synopsis string
// Hidden marks this option as hidden.
Hidden bool
// Deprecated marks this option as deprecated and contains
// a message describing why.
Deprecated string
// Type contains a string describing the type of this field,
// e.g. "[]string".
Type string
// Short is the name of the short version of a flag for this option.
Short string
// Value contains a pointer to the value for this option.
// Used by Loader machinery to set the value of this option.
Value interface{}
// DefaultValue contains the default value of this option.
DefaultValue interface{}
// DefaultString contains a more human-friendly description
// of the default value, e.g. os.Stderr instead of io.Writer.
DefaultString string
// IsSet is true if this value has been set.
// Used by Loader machinery.
// TODO ugly.
IsSet bool
}
// Arg defines a positional argument of a Cmd.
//
// Usually generated by the `cli` code generator.
type Arg struct {
// Name is the name of this argument.
Name string
// Type contains a string describing the type of this field,
// e.g. "[]string".
Type string
// Variadic is true if this function argument is variadic,
// e.g. func example(a string, b ...string)
// "b" is variadic.
Variadic bool
// Value contains a pointer to the value for this argument.
// Used by `cli` machinery to set the value of this argument.
Value interface{}
}