OLD | NEW |
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 library args.command_runner; | 5 library args.command_runner; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'dart:collection'; | 8 import 'dart:collection'; |
9 import 'dart:math' as math; | 9 import 'dart:math' as math; |
10 | 10 |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 usageException( | 150 usageException( |
151 'Could not find a command named "${argResults.rest[0]}".'); | 151 'Could not find a command named "${argResults.rest[0]}".'); |
152 } | 152 } |
153 | 153 |
154 command.usageException('Could not find a subcommand named ' | 154 command.usageException('Could not find a subcommand named ' |
155 '"${argResults.rest[0]}" for "$commandString".'); | 155 '"${argResults.rest[0]}" for "$commandString".'); |
156 } | 156 } |
157 } | 157 } |
158 | 158 |
159 // Step into the command. | 159 // Step into the command. |
160 var parent = command; | |
161 argResults = argResults.command; | 160 argResults = argResults.command; |
162 command = commands[argResults.name]; | 161 command = commands[argResults.name]; |
163 command._globalResults = topLevelResults; | 162 command._globalResults = topLevelResults; |
164 command._argResults = argResults; | 163 command._argResults = argResults; |
165 commands = command._subcommands; | 164 commands = command._subcommands; |
166 commandString += " ${argResults.name}"; | 165 commandString += " ${argResults.name}"; |
167 | 166 |
168 if (argResults['help']) { | 167 if (argResults['help']) { |
169 command.printUsage(); | 168 command.printUsage(); |
170 return new Future.value(); | 169 return new Future.value(); |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
376 var buffer = new StringBuffer( | 375 var buffer = new StringBuffer( |
377 'Available ${isSubcommand ? "sub" : ""}commands:'); | 376 'Available ${isSubcommand ? "sub" : ""}commands:'); |
378 for (var name in names) { | 377 for (var name in names) { |
379 buffer.writeln(); | 378 buffer.writeln(); |
380 buffer.write(' ${padRight(name, length)} ' | 379 buffer.write(' ${padRight(name, length)} ' |
381 '${commands[name].description.split("\n").first}'); | 380 '${commands[name].description.split("\n").first}'); |
382 } | 381 } |
383 | 382 |
384 return buffer.toString(); | 383 return buffer.toString(); |
385 } | 384 } |
OLD | NEW |