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

Side by Side Diff: lib/command_runner.dart

Issue 1985883002: UsageException isn't called UsageError. (Closed) Base URL: git@github.com:dart-lang/args@master
Patch Set: Created 4 years, 7 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
« no previous file with comments | « CHANGELOG.md ('k') | pubspec.yaml » ('j') | 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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 import 'dart:async'; 5 import 'dart:async';
6 import 'dart:collection'; 6 import 'dart:collection';
7 import 'dart:math' as math; 7 import 'dart:math' as math;
8 8
9 import 'src/arg_parser.dart'; 9 import 'src/arg_parser.dart';
10 import 'src/arg_results.dart'; 10 import 'src/arg_results.dart';
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 for (var name in names) { 91 for (var name in names) {
92 _commands[name] = command; 92 _commands[name] = command;
93 argParser.addCommand(name, command.argParser); 93 argParser.addCommand(name, command.argParser);
94 } 94 }
95 command._runner = this; 95 command._runner = this;
96 } 96 }
97 97
98 /// Parses [args] and invokes [Command.run] on the chosen command. 98 /// Parses [args] and invokes [Command.run] on the chosen command.
99 /// 99 ///
100 /// This always returns a [Future] in case the command is asynchronous. The 100 /// This always returns a [Future] in case the command is asynchronous. The
101 /// [Future] will throw a [UsageError] if [args] was invalid. 101 /// [Future] will throw a [UsageException] if [args] was invalid.
102 Future run(Iterable<String> args) => 102 Future run(Iterable<String> args) =>
103 new Future.sync(() => runCommand(parse(args))); 103 new Future.sync(() => runCommand(parse(args)));
104 104
105 /// Parses [args] and returns the result, converting a [FormatException] to a 105 /// Parses [args] and returns the result, converting a [FormatException] to a
106 /// [UsageException]. 106 /// [UsageException].
107 /// 107 ///
108 /// This is notionally a protected method. It may be overridden or called from 108 /// This is notionally a protected method. It may be overridden or called from
109 /// subclasses, but it shouldn't be called externally. 109 /// subclasses, but it shouldn't be called externally.
110 ArgResults parse(Iterable<String> args) { 110 ArgResults parse(Iterable<String> args) {
111 try { 111 try {
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 383
384 for (var line in lines.skip(1)) { 384 for (var line in lines.skip(1)) {
385 buffer.writeln(); 385 buffer.writeln();
386 buffer.write(' ' * (length + 5)); 386 buffer.write(' ' * (length + 5));
387 buffer.write(line); 387 buffer.write(line);
388 } 388 }
389 } 389 }
390 390
391 return buffer.toString(); 391 return buffer.toString();
392 } 392 }
OLDNEW
« no previous file with comments | « CHANGELOG.md ('k') | pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698