|
7 | 7 |
|
8 | 8 | The [Basics] showed how to access arguments for a command. They are all retrieved as strings which is fine |
9 | 9 | but it we need to say get integers or timestamps the user would have to convert from string to desired type. |
10 | | -To ease the burden on users the `cli` library offers predefined <Type>Arg and <Type>Args structure to faciliate this |
11 | | -The value of the argument can be retrieved using the command.<Type>Arg() function. For e.g |
| 10 | +To ease the burden on users the `cli` library offers predefined `{Type}Arg` and `{Type}Args` structure to faciliate this |
| 11 | +The value of the argument can be retrieved using the `command.{Type}Arg()` function. For e.g |
12 | 12 |
|
13 | 13 | <!-- { |
14 | 14 | "args" : ["10"], |
@@ -52,7 +52,7 @@ $ greet 10 |
52 | 52 | We got 10 |
53 | 53 | ``` |
54 | 54 |
|
55 | | -Instead of using the cmd.XXXArg() function to retrieve the argument value a destination for the argument can be set |
| 55 | +Instead of using the `cmd.{Type}Arg()` function to retrieve the argument value a destination for the argument can be set |
56 | 56 | for e.g |
57 | 57 |
|
58 | 58 | <!-- { |
@@ -152,9 +152,9 @@ func main() { |
152 | 152 |
|
153 | 153 | Some things to note about multi value arguments |
154 | 154 |
|
155 | | -1. They have XXXArgs type instead of XXXArg to differentiate them from single value arguments |
156 | | -2. The Max field needs to be defined to a non zero value without which it cannot be parsed |
157 | | -3. Max field value needs to be greater then the Min field value |
| 155 | +1. They are of `{Type}Args` type rather than `{Type}Arg` to differentiate them from single value arguments |
| 156 | +2. The `Max` field needs to be defined to a non zero value without which it cannot be parsed |
| 157 | +3. `Max` field value needs to be greater than the `Min` field value |
158 | 158 |
|
159 | 159 | As with single value args the destination field can be set |
160 | 160 |
|
@@ -214,11 +214,11 @@ Following multi value arguments are supported |
214 | 214 | - `TimestampArgs` |
215 | 215 |
|
216 | 216 | It goes without saying that the chain of arguments set in the Arguments slice need to be consistent. Generally a glob |
217 | | -argument(max=-1) should be set for the argument at the end of the slice. To glob args we arent interested in we coud add |
| 217 | +argument(`max=-1`) should be set for the argument at the end of the slice. To glob args we arent interested in we coud add |
218 | 218 | the following to the end of the Arguments slice and retrieve them as a slice |
219 | 219 |
|
220 | 220 | ``` |
221 | | - &StringArgs{ |
222 | | - Max: -1, |
223 | | - }, |
| 221 | +&StringArgs{ |
| 222 | + Max: -1, |
| 223 | +}, |
224 | 224 | ``` |
0 commit comments