blob: 9881b6de19fa273d0f41797ff47e3ba4a3c4b5ed [file] [log] [blame]
// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'dart:async';
import '../command.dart';
import '../executable.dart';
import '../io.dart';
import '../utils.dart';
/// Handles the `run` pub command.
class RunCommand extends PubCommand {
bool get takesArguments => true;
bool get allowTrailingOptions => false;
String get description => "Run an executable from a package.\n"
"NOTE: We are currently optimizing this command's startup time.";
String get usage => "pub run <executable> [args...]";
Future onRun() {
if ( {
usageError("Must specify an executable to run.");
var package =;
var executable =[0];
var args =;
// A command like "foo:bar" runs the "bar" script from the "foo" package.
// If there is no colon prefix, default to the root package.
if (executable.contains(":")) {
var components = split1(executable, ":");
package = components[0];
executable = components[1];
return runExecutable(this, entrypoint, package, executable, args)