From 80f30d9176e9534c510c7f3dd33ef6d7d3ab3173 Mon Sep 17 00:00:00 2001 From: Adam Barth Date: Tue, 13 Oct 2015 13:36:39 -0700 Subject: [PATCH] Don't dump a stack trace for a usage exception Instead, just print the usage. --- packages/flutter_tools/lib/executable.dart | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/packages/flutter_tools/lib/executable.dart b/packages/flutter_tools/lib/executable.dart index 1385672451..db06747998 100644 --- a/packages/flutter_tools/lib/executable.dart +++ b/packages/flutter_tools/lib/executable.dart @@ -2,6 +2,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +import 'dart:async'; +import 'dart:io'; + +import 'package:args/command_runner.dart'; import 'package:logging/logging.dart'; import 'src/commands/flutter_command_runner.dart'; @@ -20,7 +24,7 @@ import 'src/commands/trace.dart'; /// Main entry point for commands. /// /// This function is intended to be used from the [flutter] command line tool. -void main(List args) { +Future main(List args) async { Logger.root.level = Level.WARNING; Logger.root.onRecord.listen((LogRecord record) { print('${record.level.name}: ${record.message}'); @@ -30,7 +34,7 @@ void main(List args) { print(record.stackTrace); }); - new FlutterCommandRunner() + FlutterCommandRunner runner = new FlutterCommandRunner() ..addCommand(new BuildCommand()) ..addCommand(new CacheCommand()) ..addCommand(new InitCommand()) @@ -41,6 +45,12 @@ void main(List args) { ..addCommand(new RunMojoCommand()) ..addCommand(new StartCommand()) ..addCommand(new StopCommand()) - ..addCommand(new TraceCommand()) - ..run(args); + ..addCommand(new TraceCommand()); + + try { + await runner.run(args); + } on UsageException catch (e) { + print(e); + exit(1); + } }