Commit 2e878746 authored by Steve Messick's avatar Steve Messick

Improve message when target not found

parent 3cb49849
...@@ -152,10 +152,6 @@ class ApkCommand extends FlutterCommand { ...@@ -152,10 +152,6 @@ class ApkCommand extends FlutterCommand {
abbr: 'o', abbr: 'o',
defaultsTo: _kDefaultOutputPath, defaultsTo: _kDefaultOutputPath,
help: 'Output APK file.'); help: 'Output APK file.');
argParser.addOption('target',
abbr: 't',
defaultsTo: flx.defaultMainPath,
help: 'Target app path / main entry-point file.');
argParser.addOption('flx', argParser.addOption('flx',
abbr: 'f', abbr: 'f',
defaultsTo: '', defaultsTo: '',
...@@ -172,6 +168,7 @@ class ApkCommand extends FlutterCommand { ...@@ -172,6 +168,7 @@ class ApkCommand extends FlutterCommand {
argParser.addOption('keystore-key-password', argParser.addOption('keystore-key-password',
defaultsTo: '', defaultsTo: '',
help: 'Password for the entry within the keystore.'); help: 'Password for the entry within the keystore.');
addTargetOption();
} }
@override @override
......
...@@ -19,17 +19,13 @@ class BuildCommand extends FlutterCommand { ...@@ -19,17 +19,13 @@ class BuildCommand extends FlutterCommand {
// remove it once we've updated those build scripts. // remove it once we've updated those build scripts.
argParser.addOption('asset-base', help: 'Ignored. Will be removed.', hide: true); argParser.addOption('asset-base', help: 'Ignored. Will be removed.', hide: true);
argParser.addOption('compiler'); argParser.addOption('compiler');
argParser.addOption('target',
abbr: 't',
defaultsTo: defaultMainPath,
help: 'Target app path / main entry-point file.'
);
// TODO(devoncarew): Remove this once the xcode project is switched over. // TODO(devoncarew): Remove this once the xcode project is switched over.
argParser.addOption('main', hide: true); argParser.addOption('main', hide: true);
argParser.addOption('manifest', defaultsTo: defaultManifestPath); argParser.addOption('manifest', defaultsTo: defaultManifestPath);
argParser.addOption('private-key', defaultsTo: defaultPrivateKeyPath); argParser.addOption('private-key', defaultsTo: defaultPrivateKeyPath);
argParser.addOption('output-file', abbr: 'o', defaultsTo: defaultFlxOutputPath); argParser.addOption('output-file', abbr: 'o', defaultsTo: defaultFlxOutputPath);
argParser.addOption('snapshot', defaultsTo: defaultSnapshotPath); argParser.addOption('snapshot', defaultsTo: defaultSnapshotPath);
addTargetOption();
} }
Future<int> runInProject() async { Future<int> runInProject() async {
......
...@@ -7,7 +7,6 @@ import 'dart:io'; ...@@ -7,7 +7,6 @@ import 'dart:io';
import 'package:path/path.dart' as path; import 'package:path/path.dart' as path;
import '../flx.dart';
import '../globals.dart'; import '../globals.dart';
import '../runner/flutter_command.dart'; import '../runner/flutter_command.dart';
...@@ -16,11 +15,7 @@ class RefreshCommand extends FlutterCommand { ...@@ -16,11 +15,7 @@ class RefreshCommand extends FlutterCommand {
final String description = 'Build and deploy the Dart code in a Flutter app (Android only).'; final String description = 'Build and deploy the Dart code in a Flutter app (Android only).';
RefreshCommand() { RefreshCommand() {
argParser.addOption('target', addTargetOption();
abbr: 't',
defaultsTo: defaultMainPath,
help: 'Target app path / main entry-point file.'
);
} }
bool get androidOnly => true; bool get androidOnly => true;
......
...@@ -13,7 +13,6 @@ import '../base/utils.dart'; ...@@ -13,7 +13,6 @@ import '../base/utils.dart';
import '../build_configuration.dart'; import '../build_configuration.dart';
import '../dart/pub.dart'; import '../dart/pub.dart';
import '../device.dart'; import '../device.dart';
import '../flx.dart';
import '../globals.dart'; import '../globals.dart';
import '../runner/flutter_command.dart'; import '../runner/flutter_command.dart';
import '../toolchain.dart'; import '../toolchain.dart';
...@@ -43,12 +42,9 @@ abstract class RunCommandBase extends FlutterCommand { ...@@ -43,12 +42,9 @@ abstract class RunCommandBase extends FlutterCommand {
negatable: true, negatable: true,
defaultsTo: false, defaultsTo: false,
help: 'Start tracing during startup.'); help: 'Start tracing during startup.');
argParser.addOption('target',
abbr: 't',
defaultsTo: defaultMainPath,
help: 'Target app path / main entry-point file.');
argParser.addOption('route', argParser.addOption('route',
help: 'Which route to load when starting the app.'); help: 'Which route to load when starting the app.');
addTargetOption();
} }
bool get checked => argResults['checked']; bool get checked => argResults['checked'];
......
...@@ -12,6 +12,7 @@ import '../build_configuration.dart'; ...@@ -12,6 +12,7 @@ import '../build_configuration.dart';
import '../device.dart'; import '../device.dart';
import '../globals.dart'; import '../globals.dart';
import '../toolchain.dart'; import '../toolchain.dart';
import '../flx.dart' as flx;
import 'flutter_command_runner.dart'; import 'flutter_command_runner.dart';
typedef bool Validator(); typedef bool Validator();
...@@ -20,7 +21,7 @@ abstract class FlutterCommand extends Command { ...@@ -20,7 +21,7 @@ abstract class FlutterCommand extends Command {
FlutterCommandRunner get runner => super.runner; FlutterCommandRunner get runner => super.runner;
/// Whether this command needs to be run from the root of a project. /// Whether this command needs to be run from the root of a project.
bool get requiresProjectRoot => true; bool get requiresProjectRoot => !_targetSpecified;
/// Whether this command requires a (single) Flutter target device to be connected. /// Whether this command requires a (single) Flutter target device to be connected.
bool get requiresDevice => false; bool get requiresDevice => false;
...@@ -142,4 +143,14 @@ abstract class FlutterCommand extends Command { ...@@ -142,4 +143,14 @@ abstract class FlutterCommand extends Command {
return devices; return devices;
} }
bool _targetSpecified = false;
void addTargetOption() {
argParser.addOption('target',
abbr: 't',
callback: (val) => _targetSpecified = true,
defaultsTo: flx.defaultMainPath,
help: 'Target app path / main entry-point file.');
}
} }
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:flutter_tools/src/commands/run.dart';
import 'package:test/test.dart';
import 'src/common.dart';
import 'src/context.dart';
import 'src/mocks.dart';
main() => defineTests();
defineTests() {
group('run', () {
testUsingContext('fail when target not found', () {
RunCommand command = new RunCommand();
applyMocksToCommand(command);
return createTestCommandRunner(command).run(<String>['run', '-t', 'abc123']).then((int code) {
expect(code, equals(1));
});
});
});
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment