| 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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 } | 71 } |
| 72 } | 72 } |
| 73 return matches; | 73 return matches; |
| 74 } | 74 } |
| 75 | 75 |
| 76 // Returns the set of commands could be triggered by a list of | 76 // Returns the set of commands could be triggered by a list of |
| 77 // arguments. | 77 // arguments. |
| 78 List<Command> _match(List<String> args, bool preferExact) { | 78 List<Command> _match(List<String> args, bool preferExact) { |
| 79 if (args.isEmpty) { | 79 if (args.isEmpty) { |
| 80 return []; | 80 return []; |
| 81 } | 81 } |
| 82 bool lastArg = (args.length == 1); | 82 bool lastArg = (args.length == 1); |
| 83 var matches = _matchLocal(args[0], !lastArg || preferExact); | 83 var matches = _matchLocal(args[0], !lastArg || preferExact); |
| 84 if (matches.isEmpty) { | 84 if (matches.isEmpty) { |
| 85 return []; | 85 return []; |
| 86 } else if (matches.length == 1) { | 86 } else if (matches.length == 1) { |
| 87 var childMatches = matches[0]._match(args.sublist(1), preferExact); | 87 var childMatches = matches[0]._match(args.sublist(1), preferExact); |
| 88 if (childMatches.isEmpty) { | 88 if (childMatches.isEmpty) { |
| 89 return matches; | 89 return matches; |
| 90 } else { | 90 } else { |
| 91 return childMatches; | 91 return childMatches; |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 if (_parent is RootCommand) { | 240 if (_parent is RootCommand) { |
| 241 return name; | 241 return name; |
| 242 } else { | 242 } else { |
| 243 Command parent = _parent; | 243 Command parent = _parent; |
| 244 return '${parent.fullName} $name'; | 244 return '${parent.fullName} $name'; |
| 245 } | 245 } |
| 246 } | 246 } |
| 247 | 247 |
| 248 toString() => 'Command(${name})'; | 248 toString() => 'Command(${name})'; |
| 249 } | 249 } |
| OLD | NEW |