@@ -178,6 +178,14 @@ private fn getoptImpl(ref args: string[], description: string, dgt: scope dg (st
178
178
* If there are multiple instances of the flag, `_string` will have the value of the last
179
179
* instance.
180
180
*
181
+ * Example:
182
+ * ```volt
183
+ * args := ["--fruit", "apple", "--fruit", "banana", "--fruit", "pear"]
184
+ * fruit: string;
185
+ * getopt(ref args, "fruit", ref fruit);
186
+ * assert(fruit == "pear");
187
+ * ```
188
+ *
181
189
* @Param args The array of strings to remove applicable flags and arguments from.
182
190
* @Param description The description of the flag -- see `getopt`'s module documentation for details.
183
191
* @Param _string This argument will be filled with the last value parsed out of `args`.
@@ -194,7 +202,16 @@ fn getopt(ref args: string[], description: string, ref _string: string) bool
194
202
* Parse a flag taking multiple string argument from an array of strings.
195
203
*
196
204
* If a flag (described in `description`, separated by | characters) shows up in `args`[1 .. $], an argument is parsed
197
- * and put into `strings`. Both the flag and argument are then removed from `args`.
205
+ * and put into `strings`. Both the flag and argument are then removed from `args`. If there are multiple instances
206
+ * of the flag, then `strings` will contain all given arguments, in the order they appeared.
207
+ *
208
+ * Example:
209
+ * ```volt
210
+ * args := ["--fruit", "apple", "--fruit", "banana", "--fruit", "pear"]
211
+ * fruits: string[];
212
+ * getopt(ref args, "fruit", ref fruit);
213
+ * assert(fruits == ["apple", "banana", "pear"]);
214
+ * ```
198
215
*
199
216
* @Param args The array of strings to remove applicable flags and arguments from.
200
217
* @Param description The description of the flag -- see `getopt`'s module documentation for details.
0 commit comments