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

Unified Diff: pkg/front_end/lib/src/fasta/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/command_line.dart
diff --git a/pkg/front_end/lib/src/fasta/command_line.dart b/pkg/front_end/lib/src/fasta/command_line.dart
index 8916a45693b07e44fe1bddb40d7015475c324fdb..376d3bcab1eeb015becf4a094eb034024c91da8f 100644
--- a/pkg/front_end/lib/src/fasta/command_line.dart
+++ b/pkg/front_end/lib/src/fasta/command_line.dart
@@ -4,14 +4,22 @@
library fasta.command_line;
+import 'fasta_codes.dart'
+ show codeFastaCLIArgumentRequired, BoundFastaMessage, FastaMessage;
+
import 'deprecated_problems.dart'
show deprecated_inputError, deprecated_internalProblem;
-deprecated_argumentError(String usage, String message) {
- if (usage != null) print(usage);
+deprecated_argumentError(FastaMessage usage, String message) {
+ if (usage != null) print(usage.message);
deprecated_inputError(null, null, message);
}
+argumentError(FastaMessage usage, BoundFastaMessage bind) {
+ if (usage != null) print(usage.message);
+ deprecated_inputError(null, null, bind(null, -1).message);
+}
+
class ParsedArguments {
final Map<String, dynamic> options = <String, dynamic>{};
final List<String> arguments = <String>[];
@@ -24,7 +32,7 @@ class CommandLine {
final List<String> arguments;
- final String usage;
+ final FastaMessage usage;
CommandLine.parsed(ParsedArguments p, this.usage)
: this.options = p.options,
@@ -36,7 +44,7 @@ class CommandLine {
}
CommandLine(List<String> arguments,
- {Map<String, dynamic> specification, String usage})
+ {Map<String, dynamic> specification, FastaMessage usage})
: this.parsed(parse(arguments, specification, usage), usage);
bool get verbose {
@@ -72,7 +80,7 @@ class CommandLine {
/// This method performs only a limited amount of validation, but if an error
/// occurs, it will print [usage] along with a specific error message.
static ParsedArguments parse(List<String> arguments,
- Map<String, dynamic> specification, String usage) {
+ Map<String, dynamic> specification, FastaMessage usage) {
specification ??= const <String, dynamic>{};
ParsedArguments result = new ParsedArguments();
int index = arguments.indexOf("--");
@@ -89,8 +97,8 @@ class CommandLine {
String value;
if (valueSpecification != null) {
if (!iterator.moveNext()) {
- return deprecated_argumentError(
- usage, "Expected value after '$argument'.");
+ return argumentError(
+ usage, codeFastaCLIArgumentRequired.bind(argument));
}
value = iterator.current;
} else {

Powered by Google App Engine
This is Rietveld 408576698