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

Side by Side Diff: runtime/observatory/lib/src/cli/command.dart

Issue 984683002: Allow command aliases in Observatory debugger. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: code review Created 5 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | runtime/observatory/lib/src/elements/debugger.dart » ('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) 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. 7 // Splits a line into a list of string args.
8 List<String> _splitLine(String line) { 8 List<String> _splitLine(String line) {
9 var args = line.split(' ').where((arg) { 9 var args = line.split(' ').where((arg) {
10 return arg != ' ' && arg != ''; 10 return arg != ' ' && arg != '';
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 Future<List<String>> complete(List<String> args) => new Future.value([]); 43 Future<List<String>> complete(List<String> args) => new Future.value([]);
44 44
45 // Override in subclasses to provide command-specific execution. 45 // Override in subclasses to provide command-specific execution.
46 Future run(List<String> args); 46 Future run(List<String> args);
47 47
48 // Returns a list of local subcommands which match the args. 48 // Returns a list of local subcommands which match the args.
49 List<Command> _matchLocal(String arg, bool preferExact) { 49 List<Command> _matchLocal(String arg, bool preferExact) {
50 var matches = new List<Command>(); 50 var matches = new List<Command>();
51 for (var child in _children) { 51 for (var child in _children) {
52 if (child.name.startsWith(arg)) { 52 if (child.name.startsWith(arg)) {
53 if (preferExact && child.name == arg) { 53 if (preferExact && ((child.name == arg) || (child.alias == arg))) {
54 return [child]; 54 return [child];
55 } 55 }
56 matches.add(child); 56 matches.add(child);
57 } 57 }
58 } 58 }
59 return matches; 59 return matches;
60 } 60 }
61 61
62 // Returns the set of commands could be triggered by a list of 62 // Returns the set of commands could be triggered by a list of
63 // arguments. 63 // arguments.
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 } 213 }
214 214
215 toString() => 'RootCommand'; 215 toString() => 'RootCommand';
216 } 216 }
217 217
218 // A node in the command tree. 218 // A node in the command tree.
219 abstract class Command extends _CommandBase { 219 abstract class Command extends _CommandBase {
220 Command(this.name, List<Command> children) : super(children); 220 Command(this.name, List<Command> children) : super(children);
221 221
222 final String name; 222 final String name;
223 String alias;
224
223 String get fullName { 225 String get fullName {
224 if (_parent is RootCommand) { 226 if (_parent is RootCommand) {
225 return name; 227 return name;
226 } else { 228 } else {
227 Command parent = _parent; 229 Command parent = _parent;
228 return '${parent.fullName} $name'; 230 return '${parent.fullName} $name';
229 } 231 }
230 } 232 }
231 233
232 toString() => 'Command(${name})'; 234 toString() => 'Command(${name})';
233 } 235 }
OLDNEW
« no previous file with comments | « no previous file | runtime/observatory/lib/src/elements/debugger.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698