introduce globals scoped to the app's context
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
|
||||
import '../base/context.dart';
|
||||
import '../base/globals.dart';
|
||||
import '../base/process.dart';
|
||||
|
||||
// https://android.googlesource.com/platform/system/core/+/android-4.4_r1/adb/OVERVIEW.TXT
|
||||
|
||||
@@ -10,7 +10,7 @@ import 'package:path/path.dart' as path;
|
||||
|
||||
import '../application_package.dart';
|
||||
import '../base/common.dart';
|
||||
import '../base/context.dart';
|
||||
import '../base/globals.dart';
|
||||
import '../base/os.dart';
|
||||
import '../base/process.dart';
|
||||
import '../build_configuration.dart';
|
||||
|
||||
@@ -8,7 +8,7 @@ import 'dart:io';
|
||||
import 'package:archive/archive.dart';
|
||||
import 'package:path/path.dart' as path;
|
||||
|
||||
import 'base/context.dart';
|
||||
import 'base/globals.dart';
|
||||
import 'base/os.dart';
|
||||
import 'base/process.dart';
|
||||
import 'build_configuration.dart';
|
||||
|
||||
@@ -3,9 +3,8 @@
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
|
||||
final AppContext _defaultContext = new _DefaultAppContext();
|
||||
final AppContext _defaultContext = new AppContext();
|
||||
|
||||
/// A singleton for application functionality. This singleton can be different
|
||||
/// on a per-Zone basis.
|
||||
@@ -14,57 +13,42 @@ AppContext get context {
|
||||
return currentContext == null ? _defaultContext : currentContext;
|
||||
}
|
||||
|
||||
/// Display an error level message to the user. Commands should use this if they
|
||||
/// fail in some way.
|
||||
void printError(String message, [StackTrace stackTrace]) => context.printError(message, stackTrace);
|
||||
class AppContext {
|
||||
Map<Type, dynamic> _instances = <Type, dynamic>{};
|
||||
|
||||
/// Display normal output of the command. This should be used for things like
|
||||
/// progress messages, success messages, or just normal command output.
|
||||
void printStatus(String message) => context.printStatus(message);
|
||||
dynamic getVariable(Type type) {
|
||||
if (_instances.containsKey(type))
|
||||
return _instances[type];
|
||||
|
||||
/// Use this for verbose tracing output. Users can turn this output on in order
|
||||
/// to help diagnose issues with the toolchain or with their setup.
|
||||
void printTrace(String message) => context.printTrace(message);
|
||||
|
||||
abstract class AppContext {
|
||||
bool get verbose;
|
||||
set verbose(bool value);
|
||||
|
||||
void printError(String message, [StackTrace stackTrace]);
|
||||
void printStatus(String message);
|
||||
void printTrace(String message);
|
||||
}
|
||||
|
||||
class _DefaultAppContext implements AppContext {
|
||||
DateTime _startTime = new DateTime.now();
|
||||
|
||||
bool _verbose = false;
|
||||
|
||||
bool get verbose => _verbose;
|
||||
|
||||
set verbose(bool value) {
|
||||
_verbose = value;
|
||||
AppContext parent = _calcParent(Zone.current);
|
||||
return parent?.getVariable(type);
|
||||
}
|
||||
|
||||
void printError(String message, [StackTrace stackTrace]) {
|
||||
stderr.writeln(_prefix + message);
|
||||
if (stackTrace != null)
|
||||
stderr.writeln(stackTrace);
|
||||
void setVariable(Type type, dynamic instance) {
|
||||
_instances[type] = instance;
|
||||
}
|
||||
|
||||
void printStatus(String message) {
|
||||
print(_prefix + message);
|
||||
dynamic operator[](Type type) => getVariable(type);
|
||||
|
||||
void operator[]=(Type type, dynamic instance) => setVariable(type, instance);
|
||||
|
||||
AppContext _calcParent(Zone zone) {
|
||||
if (this == _defaultContext)
|
||||
return null;
|
||||
|
||||
Zone parentZone = zone.parent;
|
||||
if (parentZone == null)
|
||||
return _defaultContext;
|
||||
|
||||
AppContext deps = parentZone['context'];
|
||||
if (deps == this) {
|
||||
return _calcParent(parentZone);
|
||||
} else {
|
||||
return deps != null ? deps : _defaultContext;
|
||||
}
|
||||
}
|
||||
|
||||
void printTrace(String message) {
|
||||
if (_verbose)
|
||||
print('$_prefix- $message');
|
||||
}
|
||||
|
||||
String get _prefix {
|
||||
if (!_verbose)
|
||||
return '';
|
||||
Duration elapsed = new DateTime.now().difference(_startTime);
|
||||
return '[${elapsed.inMilliseconds.toString().padLeft(4)} ms] ';
|
||||
dynamic runInZone(dynamic method()) {
|
||||
return runZoned(method, zoneValues: {'context': this});
|
||||
}
|
||||
}
|
||||
|
||||
22
packages/flutter_tools/lib/src/base/globals.dart
Normal file
22
packages/flutter_tools/lib/src/base/globals.dart
Normal file
@@ -0,0 +1,22 @@
|
||||
// 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 '../device.dart';
|
||||
import 'context.dart';
|
||||
import 'logger.dart';
|
||||
|
||||
DeviceManager get deviceManager => context[DeviceManager];
|
||||
Logger get logger => context[Logger];
|
||||
|
||||
/// Display an error level message to the user. Commands should use this if they
|
||||
/// fail in some way.
|
||||
void printError(String message, [StackTrace stackTrace]) => logger.printError(message, stackTrace);
|
||||
|
||||
/// Display normal output of the command. This should be used for things like
|
||||
/// progress messages, success messages, or just normal command output.
|
||||
void printStatus(String message) => logger.printStatus(message);
|
||||
|
||||
/// Use this for verbose tracing output. Users can turn this output on in order
|
||||
/// to help diagnose issues with the toolchain or with their setup.
|
||||
void printTrace(String message) => logger.printTrace(message);
|
||||
65
packages/flutter_tools/lib/src/base/logger.dart
Normal file
65
packages/flutter_tools/lib/src/base/logger.dart
Normal file
@@ -0,0 +1,65 @@
|
||||
// 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 'dart:io';
|
||||
|
||||
abstract class Logger {
|
||||
bool verbose = false;
|
||||
|
||||
/// Display an error level message to the user. Commands should use this if they
|
||||
/// fail in some way.
|
||||
void printError(String message, [StackTrace stackTrace]);
|
||||
|
||||
/// Display normal output of the command. This should be used for things like
|
||||
/// progress messages, success messages, or just normal command output.
|
||||
void printStatus(String message);
|
||||
|
||||
/// Use this for verbose tracing output. Users can turn this output on in order
|
||||
/// to help diagnose issues with the toolchain or with their setup.
|
||||
void printTrace(String message);
|
||||
}
|
||||
|
||||
class StdoutLogger implements Logger {
|
||||
DateTime _startTime = new DateTime.now();
|
||||
|
||||
bool verbose = false;
|
||||
|
||||
void printError(String message, [StackTrace stackTrace]) {
|
||||
stderr.writeln(_prefix + message);
|
||||
if (stackTrace != null)
|
||||
stderr.writeln(stackTrace);
|
||||
}
|
||||
|
||||
void printStatus(String message) {
|
||||
print(_prefix + message);
|
||||
}
|
||||
|
||||
void printTrace(String message) {
|
||||
if (verbose)
|
||||
print('$_prefix- $message');
|
||||
}
|
||||
|
||||
String get _prefix {
|
||||
if (!verbose)
|
||||
return '';
|
||||
Duration elapsed = new DateTime.now().difference(_startTime);
|
||||
return '[${elapsed.inMilliseconds.toString().padLeft(4)} ms] ';
|
||||
}
|
||||
}
|
||||
|
||||
class BufferLogger implements Logger {
|
||||
StringBuffer _error = new StringBuffer();
|
||||
StringBuffer _status = new StringBuffer();
|
||||
StringBuffer _trace = new StringBuffer();
|
||||
|
||||
bool verbose = false;
|
||||
|
||||
String get errorText => _error.toString();
|
||||
String get statusText => _status.toString();
|
||||
String get traceText => _trace.toString();
|
||||
|
||||
void printError(String message, [StackTrace stackTrace]) => _error.writeln(message);
|
||||
void printStatus(String message) => _status.writeln(message);
|
||||
void printTrace(String message) => _trace.writeln(message);
|
||||
}
|
||||
@@ -6,7 +6,7 @@ import 'dart:async';
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
import 'context.dart';
|
||||
import 'globals.dart';
|
||||
|
||||
typedef String StringConverter(String string);
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import 'dart:io';
|
||||
|
||||
import 'package:path/path.dart' as path;
|
||||
|
||||
import 'base/context.dart';
|
||||
import 'base/globals.dart';
|
||||
|
||||
enum BuildType {
|
||||
prebuilt,
|
||||
|
||||
@@ -11,7 +11,7 @@ import 'package:den_api/den_api.dart';
|
||||
import 'package:path/path.dart' as path;
|
||||
|
||||
import '../artifacts.dart';
|
||||
import '../base/context.dart';
|
||||
import '../base/globals.dart';
|
||||
import '../base/process.dart';
|
||||
import '../build_configuration.dart';
|
||||
import '../runner/flutter_command.dart';
|
||||
|
||||
@@ -12,8 +12,8 @@ import 'package:yaml/yaml.dart';
|
||||
import '../android/device_android.dart';
|
||||
import '../application_package.dart';
|
||||
import '../artifacts.dart';
|
||||
import '../base/context.dart';
|
||||
import '../base/file_system.dart';
|
||||
import '../base/globals.dart';
|
||||
import '../base/process.dart';
|
||||
import '../build_configuration.dart';
|
||||
import '../device.dart';
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import '../base/context.dart';
|
||||
import '../base/globals.dart';
|
||||
import '../flx.dart';
|
||||
import '../runner/flutter_command.dart';
|
||||
import '../toolchain.dart';
|
||||
|
||||
@@ -11,7 +11,7 @@ import 'package:path/path.dart' as path;
|
||||
|
||||
import '../android/android.dart' as android;
|
||||
import '../artifacts.dart';
|
||||
import '../base/context.dart';
|
||||
import '../base/globals.dart';
|
||||
import '../base/process.dart';
|
||||
|
||||
class CreateCommand extends Command {
|
||||
|
||||
@@ -9,6 +9,8 @@ import 'dart:io';
|
||||
import '../android/adb.dart';
|
||||
import '../android/device_android.dart';
|
||||
import '../base/context.dart';
|
||||
import '../base/globals.dart';
|
||||
import '../base/logger.dart';
|
||||
import '../device.dart';
|
||||
import '../ios/device_ios.dart';
|
||||
import '../ios/simulator.dart';
|
||||
@@ -33,9 +35,11 @@ class DaemonCommand extends FlutterCommand {
|
||||
Future<int> runInProject() {
|
||||
printStatus('Starting device daemon...');
|
||||
|
||||
NotifyingAppContext appContext = new NotifyingAppContext();
|
||||
AppContext appContext = new AppContext();
|
||||
NotifyingLogger notifyingLogger = new NotifyingLogger();
|
||||
appContext[Logger] = notifyingLogger;
|
||||
|
||||
return runZoned(() {
|
||||
return appContext.runInZone(() {
|
||||
Stream<Map<String, dynamic>> commandStream = stdin
|
||||
.transform(UTF8.decoder)
|
||||
.transform(const LineSplitter())
|
||||
@@ -47,10 +51,10 @@ class DaemonCommand extends FlutterCommand {
|
||||
|
||||
Daemon daemon = new Daemon(commandStream, (Map command) {
|
||||
stdout.writeln('[${JSON.encode(command, toEncodable: _jsonEncodeObject)}]');
|
||||
}, daemonCommand: this, appContext: appContext);
|
||||
}, daemonCommand: this, notifyingLogger: notifyingLogger);
|
||||
|
||||
return daemon.onExit;
|
||||
}, zoneValues: {'context': appContext});
|
||||
});
|
||||
}
|
||||
|
||||
dynamic _jsonEncodeObject(dynamic object) {
|
||||
@@ -67,7 +71,7 @@ typedef Future<dynamic> CommandHandler(dynamic args);
|
||||
class Daemon {
|
||||
Daemon(Stream<Map> commandStream, this.sendCommand, {
|
||||
this.daemonCommand,
|
||||
this.appContext
|
||||
this.notifyingLogger
|
||||
}) {
|
||||
// Set up domains.
|
||||
_registerDomain(new DaemonDomain(this));
|
||||
@@ -83,7 +87,7 @@ class Daemon {
|
||||
|
||||
final DispatchComand sendCommand;
|
||||
final DaemonCommand daemonCommand;
|
||||
final NotifyingAppContext appContext;
|
||||
final NotifyingLogger notifyingLogger;
|
||||
|
||||
final Completer<int> _onExitCompleter = new Completer<int>();
|
||||
final Map<String, Domain> _domainMap = <String, Domain>{};
|
||||
@@ -185,7 +189,7 @@ class DaemonDomain extends Domain {
|
||||
registerHandler('version', version);
|
||||
registerHandler('shutdown', shutdown);
|
||||
|
||||
_subscription = daemon.appContext.onMessage.listen((LogMessage message) {
|
||||
_subscription = daemon.notifyingLogger.onMessage.listen((LogMessage message) {
|
||||
if (message.stackTrace != null) {
|
||||
sendEvent('daemon.logMessage', {
|
||||
'level': message.level,
|
||||
@@ -467,13 +471,11 @@ dynamic _toJsonable(dynamic obj) {
|
||||
return '$obj';
|
||||
}
|
||||
|
||||
class NotifyingAppContext implements AppContext {
|
||||
class NotifyingLogger extends Logger {
|
||||
StreamController<LogMessage> _messageController = new StreamController<LogMessage>.broadcast();
|
||||
|
||||
Stream<LogMessage> get onMessage => _messageController.stream;
|
||||
|
||||
bool verbose = false;
|
||||
|
||||
void printError(String message, [StackTrace stackTrace]) {
|
||||
_messageController.add(new LogMessage('error', message, stackTrace));
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ import "dart:io";
|
||||
import "package:path/path.dart" as path;
|
||||
|
||||
import "../artifacts.dart";
|
||||
import "../base/context.dart";
|
||||
import "../base/globals.dart";
|
||||
import "../base/process.dart";
|
||||
import "../runner/flutter_command.dart";
|
||||
import "../runner/flutter_command_runner.dart";
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import '../base/context.dart';
|
||||
import '../base/globals.dart';
|
||||
import '../device.dart';
|
||||
import '../runner/flutter_command.dart';
|
||||
|
||||
@@ -15,9 +15,7 @@ class ListCommand extends FlutterCommand {
|
||||
bool get requiresProjectRoot => false;
|
||||
|
||||
Future<int> runInProject() async {
|
||||
DeviceManager deviceManager = new DeviceManager();
|
||||
|
||||
List<Device> devices = await deviceManager.getDevices();
|
||||
List<Device> devices = await deviceManager.getAllConnectedDevices();
|
||||
|
||||
if (devices.isEmpty) {
|
||||
printStatus('No connected devices.');
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
|
||||
import '../base/context.dart';
|
||||
import '../base/globals.dart';
|
||||
import '../base/process.dart';
|
||||
import 'start.dart';
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import '../base/context.dart';
|
||||
import '../base/globals.dart';
|
||||
import '../device.dart';
|
||||
import '../runner/flutter_command.dart';
|
||||
|
||||
@@ -24,21 +24,14 @@ class LogsCommand extends FlutterCommand {
|
||||
|
||||
Future<int> runInProject() async {
|
||||
DeviceManager deviceManager = new DeviceManager();
|
||||
List<Device> devices;
|
||||
deviceManager.specifiedDeviceId = globalResults['device-id'];
|
||||
|
||||
String deviceId = globalResults['device-id'];
|
||||
if (deviceId != null) {
|
||||
Device device = await deviceManager.getDeviceById(deviceId);
|
||||
if (device == null) {
|
||||
printError("No device found with id '$deviceId'.");
|
||||
return 1;
|
||||
}
|
||||
devices = <Device>[device];
|
||||
} else {
|
||||
devices = await deviceManager.getDevices();
|
||||
}
|
||||
List<Device> devices = await deviceManager.getDevices();
|
||||
|
||||
if (devices.isEmpty) {
|
||||
if (devices.isEmpty && deviceManager.hasSpecifiedDeviceId) {
|
||||
printError("No device found with id '${deviceManager.specifiedDeviceId}'.");
|
||||
return 1;
|
||||
} else if (devices.isEmpty) {
|
||||
printStatus('No connected devices.');
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import 'dart:io';
|
||||
|
||||
import 'package:path/path.dart' as path;
|
||||
|
||||
import '../base/context.dart';
|
||||
import '../base/globals.dart';
|
||||
import '../flx.dart';
|
||||
import '../runner/flutter_command.dart';
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import 'dart:io';
|
||||
import 'package:path/path.dart' as path;
|
||||
|
||||
import '../artifacts.dart';
|
||||
import '../base/context.dart';
|
||||
import '../base/globals.dart';
|
||||
import '../base/process.dart';
|
||||
import '../build_configuration.dart';
|
||||
import '../flx.dart' as flx;
|
||||
@@ -118,7 +118,7 @@ class RunMojoCommand extends FlutterCommand {
|
||||
if (useDevtools) {
|
||||
final String buildFlag = argResults['mojo-debug'] ? '--debug' : '--release';
|
||||
args.add(buildFlag);
|
||||
if (context.verbose)
|
||||
if (logger.verbose)
|
||||
args.add('--verbose');
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ import 'package:path/path.dart' as path;
|
||||
|
||||
import '../application_package.dart';
|
||||
import '../base/common.dart';
|
||||
import '../base/context.dart';
|
||||
import '../base/globals.dart';
|
||||
import '../build_configuration.dart';
|
||||
import '../device.dart';
|
||||
import '../flx.dart';
|
||||
|
||||
@@ -9,7 +9,7 @@ import 'package:path/path.dart' as path;
|
||||
import 'package:test/src/executable.dart' as executable;
|
||||
|
||||
import '../artifacts.dart';
|
||||
import '../base/context.dart';
|
||||
import '../base/globals.dart';
|
||||
import '../build_configuration.dart';
|
||||
import '../runner/flutter_command.dart';
|
||||
import '../test/loader.dart' as loader;
|
||||
|
||||
@@ -6,7 +6,7 @@ import 'dart:async';
|
||||
|
||||
import '../android/device_android.dart';
|
||||
import '../application_package.dart';
|
||||
import '../base/context.dart';
|
||||
import '../base/globals.dart';
|
||||
import '../runner/flutter_command.dart';
|
||||
|
||||
class TraceCommand extends FlutterCommand {
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
import 'dart:async';
|
||||
|
||||
import '../artifacts.dart';
|
||||
import '../base/context.dart';
|
||||
import '../base/globals.dart';
|
||||
import '../base/process.dart';
|
||||
import '../runner/flutter_command.dart';
|
||||
import '../runner/version.dart';
|
||||
|
||||
@@ -7,33 +7,48 @@ import 'dart:async';
|
||||
import 'android/device_android.dart';
|
||||
import 'application_package.dart';
|
||||
import 'base/common.dart';
|
||||
import 'base/context.dart';
|
||||
import 'base/globals.dart';
|
||||
import 'build_configuration.dart';
|
||||
import 'ios/device_ios.dart';
|
||||
import 'toolchain.dart';
|
||||
|
||||
/// A class to get all available devices.
|
||||
class DeviceManager {
|
||||
/// Constructing DeviceManagers is cheap; they only do expensive work if some
|
||||
/// of their methods are invoked.
|
||||
DeviceManager() {
|
||||
// Init the known discoverers.
|
||||
// Register the known discoverers.
|
||||
_deviceDiscoverers.add(new AndroidDeviceDiscovery());
|
||||
_deviceDiscoverers.add(new IOSDeviceDiscovery());
|
||||
_deviceDiscoverers.add(new IOSSimulatorDiscovery());
|
||||
}
|
||||
|
||||
Future.forEach(_deviceDiscoverers, (DeviceDiscovery discoverer) {
|
||||
if (!discoverer.supportsPlatform)
|
||||
return null;
|
||||
return discoverer.init();
|
||||
}).then((_) {
|
||||
_initedCompleter.complete();
|
||||
}).catchError((error, stackTrace) {
|
||||
_initedCompleter.completeError(error, stackTrace);
|
||||
});
|
||||
Future _init() {
|
||||
if (_initedCompleter == null) {
|
||||
_initedCompleter = new Completer();
|
||||
|
||||
Future.forEach(_deviceDiscoverers, (DeviceDiscovery discoverer) {
|
||||
if (!discoverer.supportsPlatform)
|
||||
return null;
|
||||
return discoverer.init();
|
||||
}).then((_) {
|
||||
_initedCompleter.complete();
|
||||
}).catchError((error, stackTrace) {
|
||||
_initedCompleter.completeError(error, stackTrace);
|
||||
});
|
||||
}
|
||||
|
||||
return _initedCompleter.future;
|
||||
}
|
||||
|
||||
List<DeviceDiscovery> _deviceDiscoverers = <DeviceDiscovery>[];
|
||||
|
||||
Completer _initedCompleter = new Completer();
|
||||
/// A user-specified device ID.
|
||||
String specifiedDeviceId;
|
||||
|
||||
Completer _initedCompleter;
|
||||
|
||||
bool get hasSpecifiedDeviceId => specifiedDeviceId != null;
|
||||
|
||||
/// Return the device with the matching ID; else, complete the Future with
|
||||
/// `null`.
|
||||
@@ -41,15 +56,26 @@ class DeviceManager {
|
||||
/// This does a case insentitive compare with `deviceId`.
|
||||
Future<Device> getDeviceById(String deviceId) async {
|
||||
deviceId = deviceId.toLowerCase();
|
||||
List<Device> devices = await getDevices();
|
||||
List<Device> devices = await getAllConnectedDevices();
|
||||
return devices.firstWhere(
|
||||
(Device device) => device.id.toLowerCase() == deviceId,
|
||||
orElse: () => null
|
||||
);
|
||||
}
|
||||
|
||||
/// Return the list of connected devices, filtered by any user-specified device id.
|
||||
Future<List<Device>> getDevices() async {
|
||||
await _initedCompleter.future;
|
||||
if (specifiedDeviceId == null) {
|
||||
return getAllConnectedDevices();
|
||||
} else {
|
||||
Device device = await getDeviceById(specifiedDeviceId);
|
||||
return device == null ? <Device>[] : <Device>[device];
|
||||
}
|
||||
}
|
||||
|
||||
/// Return the list of all connected devices.
|
||||
Future<List<Device>> getAllConnectedDevices() async {
|
||||
await _init();
|
||||
|
||||
return _deviceDiscoverers
|
||||
.where((DeviceDiscovery discoverer) => discoverer.supportsPlatform)
|
||||
|
||||
@@ -13,7 +13,7 @@ import 'package:flx/signing.dart';
|
||||
import 'package:path/path.dart' as path;
|
||||
import 'package:yaml/yaml.dart';
|
||||
|
||||
import 'base/context.dart';
|
||||
import 'base/globals.dart';
|
||||
import 'base/file_system.dart';
|
||||
import 'toolchain.dart';
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ import 'package:path/path.dart' as path;
|
||||
|
||||
import '../application_package.dart';
|
||||
import '../base/common.dart';
|
||||
import '../base/context.dart';
|
||||
import '../base/globals.dart';
|
||||
import '../base/process.dart';
|
||||
import '../build_configuration.dart';
|
||||
import '../device.dart';
|
||||
|
||||
@@ -6,7 +6,7 @@ import 'dart:async';
|
||||
import 'dart:convert' show JSON;
|
||||
import 'dart:io';
|
||||
|
||||
import '../base/context.dart';
|
||||
import '../base/globals.dart';
|
||||
import '../base/process.dart';
|
||||
|
||||
const String _xcrunPath = '/usr/bin/xcrun';
|
||||
|
||||
@@ -8,9 +8,9 @@ import 'dart:io';
|
||||
import 'package:args/command_runner.dart';
|
||||
|
||||
import '../application_package.dart';
|
||||
import '../base/context.dart';
|
||||
import '../build_configuration.dart';
|
||||
import '../artifacts.dart';
|
||||
import '../base/globals.dart';
|
||||
import '../build_configuration.dart';
|
||||
import '../device.dart';
|
||||
import '../toolchain.dart';
|
||||
import 'flutter_command_runner.dart';
|
||||
|
||||
@@ -10,7 +10,7 @@ import 'package:args/command_runner.dart';
|
||||
import 'package:path/path.dart' as path;
|
||||
|
||||
import '../artifacts.dart';
|
||||
import '../base/context.dart';
|
||||
import '../base/globals.dart';
|
||||
import '../base/process.dart';
|
||||
import '../build_configuration.dart';
|
||||
import 'version.dart';
|
||||
@@ -158,10 +158,15 @@ class FlutterCommandRunner extends CommandRunner {
|
||||
}
|
||||
|
||||
Future<int> runCommand(ArgResults globalResults) {
|
||||
if (globalResults['verbose'])
|
||||
context.verbose = true;
|
||||
|
||||
_globalResults = globalResults;
|
||||
|
||||
// Check for verbose.
|
||||
if (globalResults['verbose'])
|
||||
logger.verbose = true;
|
||||
|
||||
// See if the user specified a specific device.
|
||||
deviceManager.specifiedDeviceId = globalResults['device-id'];
|
||||
|
||||
ArtifactStore.flutterRoot = path.normalize(path.absolute(globalResults['flutter-root']));
|
||||
if (globalResults.wasParsed('package-root'))
|
||||
ArtifactStore.packageRoot = path.normalize(path.absolute(globalResults['package-root']));
|
||||
|
||||
Reference in New Issue
Block a user