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

Side by Side Diff: pkg/args/args.dart

Issue 10918056: Add documentation for addFlag negatable option (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 3 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 /** 5 /**
6 * This library lets you define parsers for parsing raw command-line arguments 6 * This library lets you define parsers for parsing raw command-line arguments
7 * into a set of options and values using [GNU][] and [POSIX][] style options. 7 * into a set of options and values using [GNU][] and [POSIX][] style options.
8 * 8 *
9 * ## Defining options ## 9 * ## Defining options ##
10 * 10 *
11 * To use this library, you create an [ArgParser] object which will contain 11 * To use this library, you create an [ArgParser] object which will contain
12 * the set of options you support: 12 * the set of options you support:
13 * 13 *
14 * var parser = new ArgParser(); 14 * var parser = new ArgParser();
15 * 15 *
16 * Then you define a set of options on that parser using [addOption()] and 16 * Then you define a set of options on that parser using [addOption()] and
17 * [addFlag()]. The minimal way to create an option is: 17 * [addFlag()]. The minimal way to create an option is:
18 * 18 *
19 * parser.addOption('name'); 19 * parser.addOption('name');
20 * 20 *
21 * This creates an option named "name". Options must be given a value on the 21 * This creates an option named "name". Options must be given a value on the
22 * command line. If you have a simple on/off flag, you can instead use: 22 * command line. If you have a simple on/off flag, you can instead use:
23 * 23 *
24 * parser.addFlag('name'); 24 * parser.addFlag('name');
25 * 25 *
26 * Flag options will, by default, accept a 'no-' prefix to negate the option.
27 * This can be disabled as such:
28 *
29 * paser.addFlag('name', negatable: false);
30 *
26 * (From here on out "option" will refer to both "regular" options and flags. 31 * (From here on out "option" will refer to both "regular" options and flags.
27 * In cases where the distinction matters, we'll use "non-flag option".) 32 * In cases where the distinction matters, we'll use "non-flag option".)
28 * 33 *
29 * Options may have an optional single-character abbreviation: 34 * Options may have an optional single-character abbreviation:
30 * 35 *
31 * parser.addOption('mode', abbr: 'm'); 36 * parser.addOption('mode', abbr: 'm');
32 * parser.addFlag('verbose', abbr: 'v'); 37 * parser.addFlag('verbose', abbr: 'v');
33 * 38 *
34 * They may also specify a default value. The default value will be used if the 39 * They may also specify a default value. The default value will be used if the
35 * option isn't provided: 40 * option isn't provided:
(...skipping 729 matching lines...) Expand 10 before | Expand all | Expand 10 after
765 allowedBuffer.add(allowed); 770 allowedBuffer.add(allowed);
766 if (allowed == option.defaultValue) { 771 if (allowed == option.defaultValue) {
767 allowedBuffer.add(' (default)'); 772 allowedBuffer.add(' (default)');
768 } 773 }
769 first = false; 774 first = false;
770 } 775 }
771 allowedBuffer.add(']'); 776 allowedBuffer.add(']');
772 return allowedBuffer.toString(); 777 return allowedBuffer.toString();
773 } 778 }
774 } 779 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698