OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 part of cli; | 5 part of cli; |
6 | 6 |
7 // Splits a line into a list of string args. Each arg retains any | 7 // Splits a line into a list of string args. Each arg retains any |
8 // trailing whitespace so that we can reconstruct the original command | 8 // trailing whitespace so that we can reconstruct the original command |
9 // line from the pieces. | 9 // line from the pieces. |
10 List<String> _splitLine(String line) { | 10 List<String> _splitLine(String line) { |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 return name; | 246 return name; |
247 } else { | 247 } else { |
248 Command parent = _parent; | 248 Command parent = _parent; |
249 return '${parent.fullName} $name'; | 249 return '${parent.fullName} $name'; |
250 } | 250 } |
251 } | 251 } |
252 | 252 |
253 toString() => 'Command(${name})'; | 253 toString() => 'Command(${name})'; |
254 } | 254 } |
255 | 255 |
256 abstract class CommandException implements Exception {} | 256 abstract class CommandException implements Exception { |
| 257 } |
257 | 258 |
258 class AmbiguousCommandException extends CommandException { | 259 class AmbiguousCommandException extends CommandException { |
259 AmbiguousCommandException(this.command, this.matches); | 260 AmbiguousCommandException(this.command, this.matches); |
260 | 261 |
261 final String command; | 262 final String command; |
262 final List<Command> matches; | 263 final List<Command> matches; |
263 | 264 |
264 @override | 265 @override |
265 String toString() { | 266 String toString() { |
266 List<String> matchNames = | 267 List<String> matchNames = matches.map( |
267 matches.map((Command command) => '${command.fullName}').toList(); | 268 (Command command) => '${command.fullName}').toList(); |
268 return "Command '$command' is ambiguous: $matchNames"; | 269 return "Command '$command' is ambiguous: $matchNames"; |
269 } | 270 } |
270 } | 271 } |
271 | 272 |
272 class NoSuchCommandException extends CommandException { | 273 class NoSuchCommandException extends CommandException { |
273 NoSuchCommandException(this.command); | 274 NoSuchCommandException(this.command); |
274 | 275 |
275 final String command; | 276 final String command; |
276 | 277 |
277 @override | 278 @override |
278 String toString() => "No such command: '$command'"; | 279 String toString() => "No such command: '$command'"; |
279 } | 280 } |
OLD | NEW |