converge flutter run and flutter drive onto one behavior (#7688)
...for the port arguments
This commit is contained in:
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user