Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1804)

Unified Diff: bin/dartdevc.dart

Issue 2244703003: fixes #610, incorrect help output (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: fix usageexception printing Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | lib/src/analyzer/context.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: bin/dartdevc.dart
diff --git a/bin/dartdevc.dart b/bin/dartdevc.dart
index 98c3e450a2eb691b46021867f761740fa085c7f5..e6ca6a7f64d0cd9b5378f49233df31f38121b916 100755
--- a/bin/dartdevc.dart
+++ b/bin/dartdevc.dart
@@ -38,7 +38,6 @@
import 'dart:async';
import 'dart:io';
import 'package:analyzer/src/generated/engine.dart' show AnalysisEngine;
-import 'package:args/command_runner.dart';
import 'package:bazel_worker/bazel_worker.dart';
import 'package:dev_compiler/src/compiler/command.dart';
@@ -49,28 +48,10 @@ Future main(List<String> args) async {
if (args.contains('--persistent_worker')) {
new _CompilerWorker(args..remove('--persistent_worker')).run();
} else {
- exitCode = await _runCommand(args);
+ exitCode = compile(args);
}
}
-/// Runs a single compile command, and returns an exit code.
-Future<int> _runCommand(List<String> args,
- {MessageHandler messageHandler}) async {
- try {
- if (args.isEmpty || args.first != 'compile' && args.first != 'help') {
- // TODO(jmesserly): we should deprecate the commands. For now they are
- // still supported for backwards compatibility.
- args.insert(0, 'compile');
- }
- var runner = new CommandRunner('dartdevc', 'Dart Development Compiler');
- runner.addCommand(new CompileCommand(messageHandler: messageHandler));
- await runner.run(args);
- } catch (e, s) {
- return _handleError(e, s, args, messageHandler: messageHandler);
- }
- return EXIT_CODE_OK;
-}
-
/// Runs the compiler worker loop.
class _CompilerWorker extends AsyncWorkerLoop {
/// The original args supplied to the executable.
@@ -83,7 +64,7 @@ class _CompilerWorker extends AsyncWorkerLoop {
var args = _startupArgs.toList()..addAll(request.arguments);
var output = new StringBuffer();
- var exitCode = await _runCommand(args, messageHandler: output.writeln);
+ var exitCode = compile(args, printFn: output.writeln);
AnalysisEngine.instance.clearCaches();
return new WorkResponse()
..exitCode = exitCode
@@ -91,48 +72,6 @@ class _CompilerWorker extends AsyncWorkerLoop {
}
}
-/// Handles [error] in a uniform fashion. Returns the proper exit code and calls
-/// [messageHandler] with messages.
-int _handleError(dynamic error, dynamic stackTrace, List<String> args,
- {MessageHandler messageHandler}) {
- messageHandler ??= print;
-
- if (error is UsageException) {
- // Incorrect usage, input file not found, etc.
- messageHandler(error);
- return 64;
- } else if (error is CompileErrorException) {
- // Code has error(s) and failed to compile.
- messageHandler(error);
- return 1;
- } else {
- // Anything else is likely a compiler bug.
- //
- // --unsafe-force-compile is a bit of a grey area, but it's nice not to
- // crash while compiling
- // (of course, output code may crash, if it had errors).
- //
- messageHandler("");
- messageHandler("We're sorry, you've found a bug in our compiler.");
- messageHandler("You can report this bug at:");
- messageHandler(" https://github.com/dart-lang/dev_compiler/issues");
- messageHandler("");
- messageHandler(
- "Please include the information below in your report, along with");
- messageHandler(
- "any other information that may help us track it down. Thanks!");
- messageHandler("");
- messageHandler(" dartdevc arguments: " + args.join(' '));
- messageHandler(" dart --version: ${Platform.version}");
- messageHandler("");
- messageHandler("```");
- messageHandler(error);
- messageHandler(stackTrace);
- messageHandler("```");
- return 70;
- }
-}
-
/// Always returns a new modifiable list.
///
/// If the final arg is `@file_path` then read in all the lines of that file
« no previous file with comments | « no previous file | lib/src/analyzer/context.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698