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

Unified Diff: pkg/front_end/lib/src/fasta/compiler_command_line.dart

Issue 2965393002: Use FastaMessage instead of String. Part 1. (Closed)
Patch Set: Created 3 years, 5 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
Index: pkg/front_end/lib/src/fasta/compiler_command_line.dart
diff --git a/pkg/front_end/lib/src/fasta/compiler_command_line.dart b/pkg/front_end/lib/src/fasta/compiler_command_line.dart
index fca56efe5640f71627c07db506addc93d19eccbd..8226d3c06e9b5af5136e03217974c1d23fb491ff 100644
--- a/pkg/front_end/lib/src/fasta/compiler_command_line.dart
+++ b/pkg/front_end/lib/src/fasta/compiler_command_line.dart
@@ -13,6 +13,9 @@ import 'compiler_context.dart' show CompilerContext;
import 'package:kernel/target/targets.dart'
show Target, getTarget, TargetFlags, targets;
+import 'fasta_codes.dart'
+ show FastaMessage, codeFastaUsageLong, codeFastaUsageShort, codeUnspecified;
+
const Map<String, dynamic> optionSpecification = const <String, dynamic>{
"--compile-sdk": Uri,
"--fatal": ",",
@@ -128,10 +131,12 @@ class CompilerCommandLine extends CommandLine {
}
}
-String computeUsage(String programName, bool verbose) {
+FastaMessage computeUsage(String programName, bool verbose) {
String basicUsage = "Usage: $programName [options] dartfile\n";
String summary;
- String options = (verbose ? allOptions : frequentOptions).trim();
+ String options =
+ (verbose ? codeFastaUsageLong.template : codeFastaUsageShort.template)
+ .trim();
switch (programName) {
case "outline":
summary =
@@ -163,65 +168,6 @@ String computeUsage(String programName, bool verbose) {
sb.writeln();
}
sb.write(options);
- return "$sb";
+ // TODO(ahe): Don't use [codeUnspecified].
+ return codeUnspecified.bind("$sb")(null, -1);
}
-
-const String frequentOptions = """
-Frequently used options:
-
- -o <file> Generate the output into <file>.
- -h Display this message (add -v for information about all options).
-""";
-
-const String allOptions = """
-Supported options:
-
- -o <file>, --output=<file>
- Generate the output into <file>.
-
- -h, /h, /?, --help
- Display this message (add -v for information about all options).
-
- -v, --verbose
- Display verbose information.
-
- --
- Stop option parsing, the rest of the command line is assumed to be
- file names or arguments to the Dart program.
-
- --packages=<file>
- Use package resolution configuration <file>, which should contain a mapping
- of package names to paths.
-
- --platform=<file>
- Read the SDK platform from <file>, which should be in Dill/Kernel IR format
- and contain the Dart SDK.
-
- --target=none|vm|vmcc|vmreify|flutter
- Specify the target configuration.
-
- --verify
- Check that the generated output is free of various problems. This is mostly
- useful for developers of this compiler or Kernel transformations.
-
- --dump-ir
- Print compiled libraries in Kernel source notation.
-
- --exclude-source
- Do not include source code in the dill file.
-
- --compile-sdk=<patched_sdk>
- Compile the SDK from scratch instead of reading it from 'platform.dill'.
-
- --sdk=<patched_sdk>
- Location of the SDK sources for use when compiling additional platform
- libraries.
-
- --fatal=errors
- --fatal=warnings
- --fatal=nits
- Makes messages of the given kinds fatal, that is, immediately stop the
- compiler with a non-zero exit-code. In --verbose mode, also display an
- internal stack trace from the compiler. Multiple kinds can be separated by
- commas, for example, --fatal=errors,warnings.
-""";

Powered by Google App Engine
This is Rietveld 408576698