@@ -124,29 +124,40 @@ type InputInfo struct {
124124 HelpGen HelpGenerator
125125}
126126
127+ // ValueParser describes any function that takes a string and returns some type or an
128+ // error. This is the signature of any input value parser. See [ParseBool], [ParseInt],
129+ // and the other provided parsers for some examples.
127130type ValueParser = func (string ) (any , error )
128131
132+ // HelpGenerator describes any function that will return a help message based on the
133+ // [Input] that triggered it and the [CommandInfo] of which it is a member. See
134+ // [DefaultHelpGenerator] for an example.
129135type HelpGenerator = func (Input , * CommandInfo ) string
130136
137+ // Command is a parsed command structure.
131138type Command struct {
132139 Name string
133140 Inputs []Input
134141 Surplus []string
135142 Subcmd * Command
136143}
137144
145+ // Input is a parsed option value or positional argument value along with other
146+ // information such as the input ID it corresponds to and where it was parsed from.
138147type Input struct {
139148 Value any
140149 ID string
141150 RawValue string
142151 From ParsedFrom
143152}
144153
154+ // ParsedFrom describes where an Input is parsed from. The place it came from will be the
155+ // only non-zero field of this struct.
145156type ParsedFrom struct {
146- Env string // the env var's name
147- Opt string // the provided option name
148- Arg int // the position starting from 1
149- Default bool
157+ Env string // Came from this env var's name.
158+ Opt string // Came from this provided option name.
159+ Arg int // Appeared as the nth positional argument starting from 1.
160+ Default bool // Came from a provided default value.
150161}
151162
152163// Lookup looks for a parsed input value with the given id in the given Command and
0 commit comments