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

Side by Side Diff: sdk/lib/_internal/pub/lib/src/command/global_run.dart

Issue 399763002: Use ":" to separate package and executable name in pub global run. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 5 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 | sdk/lib/_internal/pub/lib/src/command/run.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) 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 pub.command.global_run; 5 library pub.command.global_run;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:io'; 8 import 'dart:io';
9 9
10 import 'package:barback/barback.dart'; 10 import 'package:barback/barback.dart';
11 import 'package:path/path.dart' as path; 11 import 'package:path/path.dart' as path;
12 import 'package:stack_trace/stack_trace.dart'; 12 import 'package:stack_trace/stack_trace.dart';
13 13
14 import '../barback/asset_environment.dart'; 14 import '../barback/asset_environment.dart';
15 import '../command.dart'; 15 import '../command.dart';
16 import '../entrypoint.dart'; 16 import '../entrypoint.dart';
17 import '../executable.dart'; 17 import '../executable.dart';
18 import '../exit_codes.dart' as exit_codes; 18 import '../exit_codes.dart' as exit_codes;
19 import '../io.dart'; 19 import '../io.dart';
20 import '../log.dart' as log; 20 import '../log.dart' as log;
21 import '../utils.dart'; 21 import '../utils.dart';
22 22
23 /// Handles the `global run` pub command. 23 /// Handles the `global run` pub command.
24 class GlobalRunCommand extends PubCommand { 24 class GlobalRunCommand extends PubCommand {
25 bool get takesArguments => true; 25 bool get takesArguments => true;
26 bool get allowTrailingOptions => false; 26 bool get allowTrailingOptions => false;
27 String get description => 27 String get description =>
28 "Run an executable from a globally activated package."; 28 "Run an executable from a globally activated package.";
29 String get usage => "pub global run <package> <executable> [args...]"; 29 String get usage => "pub global run <package>:<executable> [args...]";
30 30
31 Future onRun() { 31 Future onRun() {
32 if (commandOptions.rest.isEmpty) { 32 if (commandOptions.rest.isEmpty) {
33 usageError("Must specify a package and executable to run.");
34 }
35
36 if (commandOptions.rest.length == 1) {
37 usageError("Must specify an executable to run."); 33 usageError("Must specify an executable to run.");
38 } 34 }
39 35
40 var package = commandOptions.rest[0]; 36 if (!commandOptions.rest[0].contains(":")) {
41 var executable = commandOptions.rest[1]; 37 // TODO(rnystrom): Allow "foo" as a synonym for "foo:foo"?
nweiz 2014/07/17 07:15:10 +1
42 var args = commandOptions.rest.skip(2); 38 usageError("Must specify a package from which to run the executable.");
39 }
40
41 var parts = split1(commandOptions.rest[0], ":");
42 var package = parts[0];
43 var executable = parts[1];
44 var args = commandOptions.rest.skip(1).toList();
43 45
44 return globals.find(package).then((entrypoint) { 46 return globals.find(package).then((entrypoint) {
45 return runExecutable(this, entrypoint, package, executable, args); 47 return runExecutable(this, entrypoint, package, executable, args);
46 }).then(flushThenExit); 48 }).then(flushThenExit);
47 } 49 }
48 } 50 }
OLDNEW
« no previous file with comments | « no previous file | sdk/lib/_internal/pub/lib/src/command/run.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698