| 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 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 // argument completion from the command. | 142 // argument completion from the command. |
| 143 return commands[0]._buildCompletions(args, true); | 143 return commands[0]._buildCompletions(args, true); |
| 144 } else { | 144 } else { |
| 145 // An ambiguous prefix match leaves us nowhere. The user is | 145 // An ambiguous prefix match leaves us nowhere. The user is |
| 146 // typing a bunch of stuff that we don't know how to complete. | 146 // typing a bunch of stuff that we don't know how to complete. |
| 147 return new Future.value([]); | 147 return new Future.value([]); |
| 148 } | 148 } |
| 149 } | 149 } |
| 150 | 150 |
| 151 // We have found a set of commands which match all of the args. | 151 // We have found a set of commands which match all of the args. |
| 152 // Return the completions strings. | 152 // Return the completion strings. |
| 153 var prefix = _concatArgs(args, args.length - 1); | 153 var prefix = _concatArgs(args, args.length - 1); |
| 154 var completions = | 154 var completions = |
| 155 commands.map((command) => '${prefix}${command.name} ').toList(); | 155 commands.map((command) => '${prefix}${command.name} ').toList(); |
| 156 if (showAll && matchLen == args.length) { | 156 if (matchLen == args.length) { |
| 157 // If we are showing all possiblities, also include local | 157 // If we are showing all possiblities, also include local |
| 158 // completions for the parent command. | 158 // completions for the parent command. |
| 159 return commands[0]._parent._buildCompletions(args, false) | 159 return commands[0]._parent._buildCompletions(args, false) |
| 160 .then((localCompletions) { | 160 .then((localCompletions) { |
| 161 completions.addAll(localCompletions); | 161 completions.addAll(localCompletions); |
| 162 return completions; | 162 return completions; |
| 163 }); | 163 }); |
| 164 } | 164 } |
| 165 return new Future.value(completions); | 165 return new Future.value(completions); |
| 166 } | 166 } |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 if (_parent is RootCommand) { | 242 if (_parent is RootCommand) { |
| 243 return name; | 243 return name; |
| 244 } else { | 244 } else { |
| 245 Command parent = _parent; | 245 Command parent = _parent; |
| 246 return '${parent.fullName} $name'; | 246 return '${parent.fullName} $name'; |
| 247 } | 247 } |
| 248 } | 248 } |
| 249 | 249 |
| 250 toString() => 'Command(${name})'; | 250 toString() => 'Command(${name})'; |
| 251 } | 251 } |
| OLD | NEW |