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

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: add comment 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') | lib/src/compiler/command.dart » ('J')
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..b907226d8408ab1bd3d654d9a4b5288e6d16d3a3 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,26 +48,18 @@ Future main(List<String> args) async {
if (args.contains('--persistent_worker')) {
new _CompilerWorker(args..remove('--persistent_worker')).run();
} else {
- exitCode = await _runCommand(args);
+ exitCode = _runCommand(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);
+int _runCommand(List<String> args, {void printFn(Object obj)}) {
+ // TODO(jmesserly): this is here for backwards compatibility, we should remove
+ // it at some point.
+ if (args.isNotEmpty && args[0] == 'compile') {
+ args.removeAt(0);
}
- return EXIT_CODE_OK;
+ return compile(args, printFn: printFn);
}
/// Runs the compiler worker loop.
@@ -83,7 +74,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 = _runCommand(args, printFn: output.writeln);
AnalysisEngine.instance.clearCaches();
return new WorkResponse()
..exitCode = exitCode
@@ -91,48 +82,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') | lib/src/compiler/command.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698