| OLD | NEW |
| 1 Parses raw command-line arguments into a set of options and values. | 1 Parses raw command-line arguments into a set of options and values. |
| 2 | 2 |
| 3 This library supports [GNU][] and [POSIX][] style options, and it works | 3 This library supports [GNU][] and [POSIX][] style options, and it works |
| 4 in both server-side and client-side apps. | 4 in both server-side and client-side apps. |
| 5 | 5 |
| 6 ## Defining options | 6 ## Defining options |
| 7 | 7 |
| 8 First create an [ArgParser][]: | 8 First create an [ArgParser][]: |
| 9 | 9 |
| 10 var parser = new ArgParser(); | 10 var parser = new ArgParser(); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 allowed set of values. When you do, the parser throws a [FormatException] if the | 46 allowed set of values. When you do, the parser throws a [FormatException] if the |
| 47 value for an option is not in the allowed set. Here's an example of specifying | 47 value for an option is not in the allowed set. Here's an example of specifying |
| 48 allowed values: | 48 allowed values: |
| 49 | 49 |
| 50 parser.addOption('mode', allowed: ['debug', 'release']); | 50 parser.addOption('mode', allowed: ['debug', 'release']); |
| 51 | 51 |
| 52 You can use the `callback` parameter to associate a function with an option. | 52 You can use the `callback` parameter to associate a function with an option. |
| 53 Later, when parsing occurs, the callback function is invoked with the value of | 53 Later, when parsing occurs, the callback function is invoked with the value of |
| 54 the option: | 54 the option: |
| 55 | 55 |
| 56 parser.addOption('mode', callback: (mode) => print('Got mode $mode)); | 56 parser.addOption('mode', callback: (mode) => print('Got mode $mode')); |
| 57 parser.addFlag('verbose', callback: (verbose) { | 57 parser.addFlag('verbose', callback: (verbose) { |
| 58 if (verbose) print('Verbose'); | 58 if (verbose) print('Verbose'); |
| 59 }); | 59 }); |
| 60 | 60 |
| 61 The callbacks for all options are called whenever a set of arguments is parsed. | 61 The callbacks for all options are called whenever a set of arguments is parsed. |
| 62 If an option isn't provided in the args, its callback is passed the default | 62 If an option isn't provided in the args, its callback is passed the default |
| 63 value, or `null` if no default value is set. | 63 value, or `null` if no default value is set. |
| 64 | 64 |
| 65 ## Parsing arguments | 65 ## Parsing arguments |
| 66 | 66 |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 [posix]: http://pubs.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap12.html
#tag_12_02 | 240 [posix]: http://pubs.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap12.html
#tag_12_02 |
| 241 [gnu]: http://www.gnu.org/prep/standards/standards.html#Command_002dLine-Interfa
ces | 241 [gnu]: http://www.gnu.org/prep/standards/standards.html#Command_002dLine-Interfa
ces |
| 242 [ArgParser]: https://api.dartlang.org/apidocs/channels/stable/dartdoc-viewer/arg
s/args.ArgParser | 242 [ArgParser]: https://api.dartlang.org/apidocs/channels/stable/dartdoc-viewer/arg
s/args.ArgParser |
| 243 [ArgResults]: https://api.dartlang.org/apidocs/channels/stable/dartdoc-viewer/ar
gs/args.ArgResults | 243 [ArgResults]: https://api.dartlang.org/apidocs/channels/stable/dartdoc-viewer/ar
gs/args.ArgResults |
| 244 [addOption]: https://api.dartlang.org/apidocs/channels/stable/dartdoc-viewer/arg
s/args.ArgParser#id_addOption | 244 [addOption]: https://api.dartlang.org/apidocs/channels/stable/dartdoc-viewer/arg
s/args.ArgParser#id_addOption |
| 245 [addFlag]: https://api.dartlang.org/apidocs/channels/stable/dartdoc-viewer/args/
args.ArgParser#id_addFlag | 245 [addFlag]: https://api.dartlang.org/apidocs/channels/stable/dartdoc-viewer/args/
args.ArgParser#id_addFlag |
| 246 [parse]: https://api.dartlang.org/apidocs/channels/stable/dartdoc-viewer/args/ar
gs.ArgParser#id_parse | 246 [parse]: https://api.dartlang.org/apidocs/channels/stable/dartdoc-viewer/args/ar
gs.ArgParser#id_parse |
| 247 [rest]: https://api.dartlang.org/apidocs/channels/stable/dartdoc-viewer/args/arg
s.ArgResults#id_rest | 247 [rest]: https://api.dartlang.org/apidocs/channels/stable/dartdoc-viewer/args/arg
s.ArgResults#id_rest |
| 248 [addCommand]: https://api.dartlang.org/apidocs/channels/stable/dartdoc-viewer/ar
gs/args.ArgParser#id_addCommand | 248 [addCommand]: https://api.dartlang.org/apidocs/channels/stable/dartdoc-viewer/ar
gs/args.ArgParser#id_addCommand |
| 249 [getUsage]: https://api.dartlang.org/apidocs/channels/stable/dartdoc-viewer/args
/args.ArgParser#id_getUsage | 249 [getUsage]: https://api.dartlang.org/apidocs/channels/stable/dartdoc-viewer/args
/args.ArgParser#id_getUsage |
| OLD | NEW |