@@ -11,27 +11,32 @@ import (
11
11
const anyOption = "*"
12
12
13
13
// ParseWith is the method which parses command line arguments with option configurations.
14
- // This function divides command line arguments to command arguments and options.
14
+ // This method divides command line arguments to command arguments and options.
15
+ //
15
16
// And an option consists of a name and an option argument.
16
17
// Options are separated to long format options and short format options.
17
- // About long/short format options, since they are same with Parse function, see the comment of
18
- // that function.
18
+ // About long/short format options, since they are same with Parse method, see the comment of
19
+ // that method.
20
+ //
21
+ // This method allows only options declared in option configurations, basically.
22
+ // An option configuration has fields: StoreKey, Names, HasArg, IsArray, Defaults, Desc,
23
+ // ArgInHelp, and Validator.
19
24
//
20
- // This function allows only options declared in option configurations.
21
- // An option configuration has fields: StoreKey, Names, HasArg, IsArray, Defaults, Desc and
22
- // ArgInHelp.
23
- // When an option matches one of the Names in an option configuration, the option is registered
25
+ // When an option matches one of the Names in the option configurations, the option is registered
24
26
// into Cmd with StoreKey.
25
- // If both HasArg and IsArray are true, the option can have one or multiple option argumentsr , and
27
+ // If both HasArg and IsArray are true, the option can have one or multiple option arguments , and
26
28
// if HasArg is true and IsArray is false, the option can have only one option argument, otherwise
27
29
// the option cannot have option arguments.
28
30
// If Defaults field is specified and no option value is given in command line arguments, the value
29
31
// of Defaults is set as the option arguments.
30
32
//
31
- // If options not declared in option configurationsi are given in command line arguments, this
32
- // function basically returns UnconfiguradOption error.
33
+ // If options not declared in option configurations are given in command line arguments, this
34
+ // method basically returns UnconfiguradOption error.
33
35
// However, if you want to allow other options, add an option configuration of which StoreKey or
34
36
// the first element of Names is "*".
37
+ //
38
+ // The option configurations used to parsing are set into this Cmd instance, and it can be
39
+ // retrieved from its field: Cmd#OptCfgs.
35
40
func (cmd * Cmd ) ParseWith (optCfgs []OptCfg ) error {
36
41
_ , err := cmd .parseArgsWith (optCfgs , false )
37
42
cmd .OptCfgs = optCfgs
@@ -46,6 +51,9 @@ func (cmd *Cmd) ParseWith(optCfgs []OptCfg) error {
46
51
//
47
52
// This method parses command line arguments in the same way as the Cmd#parse_with method,
48
53
// except that it only parses the command line arguments before the first command argument.
54
+ //
55
+ // The option configurations used to parsing are set into this Cmd instance, and it can be
56
+ // retrieved from its field: Cmd#OptCfgs.
49
57
func (cmd * Cmd ) ParseUntilSubCmdWith (optCfgs []OptCfg ) (Cmd , error ) {
50
58
idx , err := cmd .parseArgsWith (optCfgs , true )
51
59
cmd .OptCfgs = optCfgs
0 commit comments