Skip to content

Commit fa084df

Browse files
committed
getopt: Add support for string multiple string arguments
1 parent 1bc5b15 commit fa084df

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/watt/text/getopt.volt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,24 @@ fn getopt(ref args: string[], description: string, ref _string: string) bool
190190
return getoptImpl(ref args, description, dgt);
191191
}
192192

193+
/*!
194+
* Parse a flag taking multiple string argument from an array of strings.
195+
*
196+
* 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`.
198+
*
199+
* @Param args The array of strings to remove applicable flags and arguments from.
200+
* @Param description The description of the flag -- see `getopt`'s module documentation for details.
201+
* @Param strings This argument will be filled with the arguments of the flag value parsed out of `args`.
202+
* @Returns `true` if an argument was removed from `args`.
203+
*/
204+
fn getopt(ref args: string[], description: string, ref strings: string[]) bool
205+
{
206+
strings = null;
207+
fn dgt(param: string) { strings ~= param; }
208+
return getoptImpl(ref args, description, dgt);
209+
}
210+
193211
/*!
194212
* Parse a flag that takes an integer argument from an array of strings.
195213
*

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy