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

Issue 10335007: First pass at a generic reusable command line option parser. (Closed)

Created:
8 years, 7 months ago by Bob Nystrom
Modified:
8 years, 7 months ago
CC:
reviews_dartlang.org, Emily Fortuna, Bill Hesse
Visibility:
Public.

Description

First pass at a generic reusable command line option parser. This parses robustly, displays pretty usage, and has good tests. It is not totally feature-full yet, but this should be a good first patch to review. Committed: https://code.google.com/p/dart/source/detail?r=7343

Patch Set 1 #

Total comments: 2

Patch Set 2 : Removing stale #import from unittest. #

Total comments: 10

Patch Set 3 : Javadoc comments. #

Total comments: 75

Patch Set 4 : Respond to review. #

Total comments: 8

Patch Set 5 : Respond to review. #

Patch Set 6 : Respond to review. #

Unified diffs Side-by-side diffs Delta from patch set Stats (+1529 lines, -4 lines) Patch
A lib/args/args.dart View 1 2 3 4 5 1 chunk +729 lines, -0 lines 0 comments Download
A lib/args/example.dart View 1 2 3 4 5 1 chunk +131 lines, -0 lines 0 comments Download
A lib/args/utils.dart View 1 2 1 chunk +19 lines, -0 lines 0 comments Download
M lib/unittest/unittest.dart View 1 2 3 4 5 chunks +62 lines, -4 lines 0 comments Download
A tests/lib/args/args_test.dart View 1 2 3 4 5 1 chunk +588 lines, -0 lines 0 comments Download

Messages

Total messages: 12 (0 generated)
Bob Nystrom
CC-ing Emily and Bill to see what they think since this could replace the code ...
8 years, 7 months ago (2012-05-02 21:48:11 UTC) #1
Bob Nystrom
https://chromiumcodereview.appspot.com/10335007/diff/1/lib/unittest/unittest.dart File lib/unittest/unittest.dart (right): https://chromiumcodereview.appspot.com/10335007/diff/1/lib/unittest/unittest.dart#newcode123 lib/unittest/unittest.dart:123: #import('../args/args.dart'); Oops! This is temp code. Don't worry about ...
8 years, 7 months ago (2012-05-02 21:48:55 UTC) #2
Bob Nystrom
Adding Siggy for the unittest changes. https://chromiumcodereview.appspot.com/10335007/diff/1/lib/unittest/unittest.dart File lib/unittest/unittest.dart (right): https://chromiumcodereview.appspot.com/10335007/diff/1/lib/unittest/unittest.dart#newcode123 lib/unittest/unittest.dart:123: #import('../args/args.dart'); On 2012/05/02 ...
8 years, 7 months ago (2012-05-02 21:52:42 UTC) #3
Siggi Cherem (dart-lang)
https://chromiumcodereview.appspot.com/10335007/diff/5001/lib/args/example.dart File lib/args/example.dart (right): https://chromiumcodereview.appspot.com/10335007/diff/5001/lib/args/example.dart#newcode25 lib/args/example.dart:25: 'none': 'Do not compile the Dart code (run native ...
8 years, 7 months ago (2012-05-02 22:07:42 UTC) #4
Bob Nystrom
https://chromiumcodereview.appspot.com/10335007/diff/5001/lib/args/example.dart File lib/args/example.dart (right): https://chromiumcodereview.appspot.com/10335007/diff/5001/lib/args/example.dart#newcode25 lib/args/example.dart:25: 'none': 'Do not compile the Dart code (run native ...
8 years, 7 months ago (2012-05-03 00:23:40 UTC) #5
Siggi Cherem (dart-lang)
changes to unittest lgtm https://chromiumcodereview.appspot.com/10335007/diff/8001/lib/unittest/unittest.dart File lib/unittest/unittest.dart (right): https://chromiumcodereview.appspot.com/10335007/diff/8001/lib/unittest/unittest.dart#newcode251 lib/unittest/unittest.dart:251: // all of the solo-ed ...
8 years, 7 months ago (2012-05-03 00:32:41 UTC) #6
Bob Nystrom
On 2012/05/03 00:32:41, sigmund wrote: > changes to unittest lgtm > > https://chromiumcodereview.appspot.com/10335007/diff/8001/lib/unittest/unittest.dart > File ...
8 years, 7 months ago (2012-05-03 00:46:20 UTC) #7
nweiz
https://chromiumcodereview.appspot.com/10335007/diff/7001/lib/args/args.dart File lib/args/args.dart (right): https://chromiumcodereview.appspot.com/10335007/diff/7001/lib/args/args.dart#newcode22 lib/args/args.dart:22: * command line. If you have a simple on/off ...
8 years, 7 months ago (2012-05-03 21:07:07 UTC) #8
Bob Nystrom
Thanks! https://chromiumcodereview.appspot.com/10335007/diff/7001/lib/args/args.dart File lib/args/args.dart (right): https://chromiumcodereview.appspot.com/10335007/diff/7001/lib/args/args.dart#newcode22 lib/args/args.dart:22: * command line. If you have a simple ...
8 years, 7 months ago (2012-05-03 22:31:19 UTC) #9
nweiz
https://chromiumcodereview.appspot.com/10335007/diff/7001/lib/args/args.dart File lib/args/args.dart (right): https://chromiumcodereview.appspot.com/10335007/diff/7001/lib/args/args.dart#newcode40 lib/args/args.dart:40: * parser.addFlag('verbose', defaultsTo: false); On 2012/05/03 22:31:19, Bob Nystrom ...
8 years, 7 months ago (2012-05-03 23:47:52 UTC) #10
Bob Nystrom
Thanks! https://chromiumcodereview.appspot.com/10335007/diff/7001/lib/args/args.dart File lib/args/args.dart (right): https://chromiumcodereview.appspot.com/10335007/diff/7001/lib/args/args.dart#newcode40 lib/args/args.dart:40: * parser.addFlag('verbose', defaultsTo: false); On 2012/05/03 23:47:52, nweiz ...
8 years, 7 months ago (2012-05-04 18:26:03 UTC) #11
nweiz
8 years, 7 months ago (2012-05-04 18:30:51 UTC) #12
lgtm

https://chromiumcodereview.appspot.com/10335007/diff/7001/lib/args/args.dart
File lib/args/args.dart (right):

https://chromiumcodereview.appspot.com/10335007/diff/7001/lib/args/args.dart#...
lib/args/args.dart:133: *         allowedHelp: {
On 2012/05/04 18:26:03, Bob Nystrom wrote:
> On 2012/05/03 23:47:52, nweiz wrote:
> > On 2012/05/03 22:31:19, Bob Nystrom wrote:
> > > On 2012/05/03 21:07:07, nweiz wrote:
> > > > allowedHelp sounds awkward. Why not just allow "allowed" to take a hash?
> We
> > > have
> > > > optional types after all.
> > > 
> > > My motivation is that it doesn't require the two to be perfectly in sync.
> > > test.dart has a couple of cases where the allowed help is a little
different
> > > from the actual allowed set of values.
> > 
> > That seems like a pretty narrow edge case to make the general case worse.
Why
> > not just allow null as a key in the hash to indicate an undocumented option?
> 
> I'm still a little leery of mixing the help directly in the allowed set by
using
> a map. I kind of like help being split out separately (even though it is a bit
> redundant), and I can see us extended the allowed API in ways that wouldn't
play
> nice. For example, test.dart's --runtime option supports both "ff" and
"firefox"
> to mean the same thing. It might be nice for args to know that and
automatically
> canonicalize them like:
> 
> allowed: ['ie', ['ff', 'firefox'], 'safari']
> 
> Or something like that. Extending the API like that gets harder if we commit
to
> using a map, I think.

If that is a case we want to support in the future, we can add allowedHelp for
that specific case. I don't think we should enforce redundancy in the common
case in order to potentially eliminate redundancy in an uncommon edge case some
time in the future.

Powered by Google App Engine
This is Rietveld 408576698