Commit b84ba91c authored by Devon Carew's avatar Devon Carew

Merge pull request #2657 from devoncarew/tool_ui

misc tool ui changes
parents 229253f4 4daee0cc
...@@ -42,6 +42,12 @@ Future<Null> main(List<String> args) async { ...@@ -42,6 +42,12 @@ Future<Null> main(List<String> args) async {
bool verbose = args.contains('-v') || args.contains('--verbose'); bool verbose = args.contains('-v') || args.contains('--verbose');
bool verboseHelp = help && verbose; bool verboseHelp = help && verbose;
if (verboseHelp) {
// Remove the verbose option; for help, users don't need to see verbose logs.
args = new List<String>.from(args);
args.removeWhere((String option) => option == '-v' || option == '--verbose');
}
FlutterCommandRunner runner = new FlutterCommandRunner(verboseHelp: verboseHelp) FlutterCommandRunner runner = new FlutterCommandRunner(verboseHelp: verboseHelp)
..addCommand(new AnalyzeCommand()) ..addCommand(new AnalyzeCommand())
..addCommand(new ApkCommand()) ..addCommand(new ApkCommand())
...@@ -75,7 +81,10 @@ Future<Null> main(List<String> args) async { ...@@ -75,7 +81,10 @@ Future<Null> main(List<String> args) async {
exit(result); exit(result);
}, onError: (dynamic error, Chain chain) { }, onError: (dynamic error, Chain chain) {
if (error is UsageException) { if (error is UsageException) {
stderr.writeln(error); stderr.writeln(error.message);
stderr.writeln();
stderr.writeln("Run 'flutter -h' (or 'flutter <command> -h') for available "
"flutter commands and options.");
// Argument error exit code. // Argument error exit code.
exit(64); exit(64);
} else if (error is ProcessExit) { } else if (error is ProcessExit) {
......
...@@ -21,7 +21,7 @@ String _getNameForHostPlatform(HostPlatform platform) { ...@@ -21,7 +21,7 @@ String _getNameForHostPlatform(HostPlatform platform) {
} }
} }
String _getNameForTargetPlatform(TargetPlatform platform) { String getNameForTargetPlatform(TargetPlatform platform) {
switch (platform) { switch (platform) {
case TargetPlatform.android_arm: case TargetPlatform.android_arm:
return 'android-arm'; return 'android-arm';
...@@ -63,7 +63,7 @@ class Artifact { ...@@ -63,7 +63,7 @@ class Artifact {
String get platform { String get platform {
if (targetPlatform != null) if (targetPlatform != null)
return _getNameForTargetPlatform(targetPlatform); return getNameForTargetPlatform(targetPlatform);
if (hostPlatform != null) if (hostPlatform != null)
return _getNameForHostPlatform(hostPlatform); return _getNameForHostPlatform(hostPlatform);
assert(false); assert(false);
......
...@@ -29,9 +29,7 @@ class DevicesCommand extends FlutterCommand { ...@@ -29,9 +29,7 @@ class DevicesCommand extends FlutterCommand {
printStatus('No connected devices.'); printStatus('No connected devices.');
} else { } else {
printStatus('${devices.length} connected ${pluralize('device', devices.length)}:\n'); printStatus('${devices.length} connected ${pluralize('device', devices.length)}:\n');
Device.printDevices(devices);
for (Device device in devices)
printStatus(device.fullDescription);
} }
return 0; return 0;
......
...@@ -3,12 +3,15 @@ ...@@ -3,12 +3,15 @@
// found in the LICENSE file. // found in the LICENSE file.
import 'dart:async'; import 'dart:async';
import 'dart:math' as math;
import 'android/android_device.dart'; import 'android/android_device.dart';
import 'application_package.dart'; import 'application_package.dart';
import 'artifacts.dart';
import 'base/common.dart'; import 'base/common.dart';
import 'base/utils.dart'; import 'base/utils.dart';
import 'build_configuration.dart'; import 'build_configuration.dart';
import 'globals.dart';
import 'ios/devices.dart'; import 'ios/devices.dart';
import 'ios/simulators.dart'; import 'ios/simulators.dart';
import 'toolchain.dart'; import 'toolchain.dart';
...@@ -140,11 +143,6 @@ abstract class Device { ...@@ -140,11 +143,6 @@ abstract class Device {
bool get supportsStartPaused => true; bool get supportsStartPaused => true;
String get fullDescription {
String supportIndicator = isSupported() ? '' : ' - unsupported';
return '$name ($id)$supportIndicator';
}
/// Whether it is an emulated device running on localhost. /// Whether it is an emulated device running on localhost.
bool get isLocalEmulator; bool get isLocalEmulator;
...@@ -202,6 +200,23 @@ abstract class Device { ...@@ -202,6 +200,23 @@ abstract class Device {
} }
String toString() => name; String toString() => name;
static void printDevices(List<Device> devices) {
int nameWidth = 0;
int idWidth = 0;
for (Device device in devices) {
nameWidth = math.max(nameWidth, device.name.length);
idWidth = math.max(idWidth, device.id.length);
}
for (Device device in devices) {
String supportIndicator = device.isSupported() ? '' : ' (unsupported)';
printStatus('${device.name.padRight(nameWidth)} • '
'${device.id.padRight(idWidth)} • '
'${getNameForTargetPlatform(device.platform)}$supportIndicator');
}
}
} }
class ForwardedPort { class ForwardedPort {
......
...@@ -47,8 +47,8 @@ abstract class FlutterCommand extends Command { ...@@ -47,8 +47,8 @@ abstract class FlutterCommand extends Command {
Stopwatch stopwatch = new Stopwatch()..start(); Stopwatch stopwatch = new Stopwatch()..start();
return _run().then((int exitCode) { return _run().then((int exitCode) {
printTrace("'flutter $name' exiting with code $exitCode; " int ms = stopwatch.elapsedMilliseconds;
"elasped time ${stopwatch.elapsedMilliseconds}ms."); printTrace("'flutter $name' took ${ms}ms; exiting with code $exitCode.");
return exitCode; return exitCode;
}); });
} }
...@@ -90,8 +90,7 @@ abstract class FlutterCommand extends Command { ...@@ -90,8 +90,7 @@ abstract class FlutterCommand extends Command {
"the '-d <deviceId>' flag."); "the '-d <deviceId>' flag.");
printStatus(''); printStatus('');
devices = await deviceManager.getAllConnectedDevices(); devices = await deviceManager.getAllConnectedDevices();
for (Device device in devices) Device.printDevices(devices);
printStatus(device.fullDescription);
return 1; return 1;
} else { } else {
_deviceForCommand = devices.single; _deviceForCommand = devices.single;
......
...@@ -72,9 +72,7 @@ class Template { ...@@ -72,9 +72,7 @@ class Template {
.replaceAll(_kCopyTemplateExtension, '') .replaceAll(_kCopyTemplateExtension, '')
.replaceAll(_kTemplateExtension, ''); .replaceAll(_kTemplateExtension, '');
File finalDestinationFile = new File(finalDestinationPath); File finalDestinationFile = new File(finalDestinationPath);
String relativePathForLogging = relativeDestPath String relativePathForLogging = path.relative(finalDestinationFile.path);
.replaceAll(_kCopyTemplateExtension, '')
.replaceAll(_kTemplateExtension, '');
// Step 1: Check if the file needs to be overwritten. // Step 1: Check if the file needs to be overwritten.
......
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