Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(268)

Side by Side Diff: pkg/args/README.md

Issue 363083002: Allow defining a help string for an option's parameter value. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 You can automatically generate nice help text, suitable for use as the output of 202 You can automatically generate nice help text, suitable for use as the output of
203 `--help`. To display good usage information, you should provide some help text 203 `--help`. To display good usage information, you should provide some help text
204 when you create your options. 204 when you create your options.
205 205
206 To define help text for an entire option, use the `help:` parameter: 206 To define help text for an entire option, use the `help:` parameter:
207 207
208 parser.addOption('mode', help: 'The compiler configuration', 208 parser.addOption('mode', help: 'The compiler configuration',
209 allowed: ['debug', 'release']); 209 allowed: ['debug', 'release']);
210 parser.addFlag('verbose', help: 'Show additional diagnostic info'); 210 parser.addFlag('verbose', help: 'Show additional diagnostic info');
211 211
212 For non-flag options, you can also provide a help string for the parameter:
nweiz 2014/07/02 19:41:32 "help string" -> "name"
Bob Nystrom 2014/07/07 20:37:34 I think I like "help string" here. I want people t
nweiz 2014/07/07 20:52:00 Again, I think "help" is strongly tied to prose de
213
214 parser.addOption('out', help: 'The output path', helpValue: 'path',
215 allowed: ['debug', 'release']);
216
212 For non-flag options, you can also provide detailed help for each expected value 217 For non-flag options, you can also provide detailed help for each expected value
213 by using the `allowedHelp:` parameter: 218 by using the `allowedHelp:` parameter:
214 219
215 parser.addOption('arch', help: 'The architecture to compile for', 220 parser.addOption('arch', help: 'The architecture to compile for',
216 allowedHelp: { 221 allowedHelp: {
217 'ia32': 'Intel x86', 222 'ia32': 'Intel x86',
218 'arm': 'ARM Holding 32-bit chip' 223 'arm': 'ARM Holding 32-bit chip'
219 }); 224 });
220 225
221 To display the help, use the [getUsage()][getUsage] method: 226 To display the help, use the [getUsage()][getUsage] method:
222 227
223 print(parser.getUsage()); 228 print(parser.getUsage());
224 229
225 The resulting string looks something like this: 230 The resulting string looks something like this:
226 231
227 --mode The compiler configuration 232 --mode The compiler configuration
228 [debug, release] 233 [debug, release]
229 234
235 --out=<path> The output path
230 --[no-]verbose Show additional diagnostic info 236 --[no-]verbose Show additional diagnostic info
231 --arch The architecture to compile for 237 --arch The architecture to compile for
232
233 [arm] ARM Holding 32-bit chip 238 [arm] ARM Holding 32-bit chip
234 [ia32] Intel x86 239 [ia32] Intel x86
235 240
236 To assist the formatting of the usage help, single-line help text is followed by
237 a single new line. Options with multi-line help text are followed by two new
238 lines. This provides spatial diversity between options.
nweiz 2014/07/02 19:41:32 This change should probably also be mentioned in t
Bob Nystrom 2014/07/07 20:37:34 There's no behavioral change here. I just took the
239
240 [posix]: http://pubs.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap12.html #tag_12_02 241 [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 242 [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 243 [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 244 [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 245 [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 246 [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 247 [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 248 [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 249 [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 250 [getUsage]: https://api.dartlang.org/apidocs/channels/stable/dartdoc-viewer/args /args.ArgParser#id_getUsage
OLDNEW
« pkg/args/CHANGELOG.md ('K') | « pkg/args/CHANGELOG.md ('k') | pkg/args/lib/args.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698