Commit a67c79a1 authored by Ian Hickson's avatar Ian Hickson Committed by GitHub

converge flutter run and flutter drive onto one behavior (#7688)

...for the port arguments
parent 19d22c97
......@@ -8,7 +8,6 @@ import 'platform.dart';
const int kDefaultObservatoryPort = 8100;
const int kDefaultDiagnosticPort = 8101;
const int kDefaultDrivePort = 8183;
/// Return the absolute path of the user's home directory
String get homeDirPath {
......
......@@ -84,9 +84,6 @@ class DriveCommand extends RunCommandBase {
// ignore: cancel_subscriptions
StreamSubscription<String> _deviceLogSubscription;
int get observatoryPort => int.parse(argResults['observatory-port']);
int get diagnosticPort => int.parse(argResults['diagnostic-port']);
@override
Future<Null> verifyThenRunCommand() async {
commandValidator();
......
......@@ -189,24 +189,6 @@ class RunCommand extends RunCommandBase {
return null;
}
int observatoryPort;
if (argResults['observatory-port'] != null) {
try {
observatoryPort = int.parse(argResults['observatory-port']);
} catch (error) {
throwToolExit('Invalid port for `--observatory-port`: $error');
}
}
int diagnosticPort;
if (argResults['diagnostic-port'] != null) {
try {
diagnosticPort = int.parse(argResults['diagnostic-port']);
} catch (error) {
throwToolExit('Invalid port for `--diagnostic-port`: $error');
}
}
if (device.isLocalEmulator && !isEmulatorBuildMode(getBuildMode()))
throwToolExit('${toTitleCase(getModeName(getBuildMode()))} mode is not supported for emulators.');
......
......@@ -76,6 +76,28 @@ abstract class FlutterCommand extends Command<Null> {
);
}
int get observatoryPort {
if (argResults['observatory-port'] != null) {
try {
return int.parse(argResults['observatory-port']);
} catch (error) {
throwToolExit('Invalid port for `--observatory-port`: $error');
}
}
return null;
}
int get diagnosticPort {
if (argResults['diagnostic-port'] != null) {
try {
return int.parse(argResults['diagnostic-port']);
} catch (error) {
throwToolExit('Invalid port for `--diagnostic-port`: $error');
}
}
return null;
}
void addBuildModeFlags({ bool defaultToRelease: true }) {
defaultBuildMode = defaultToRelease ? BuildMode.release : BuildMode.debug;
......
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