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

Unified Diff: pkg/analyzer_cli/lib/src/options.dart

Issue 1525623003: CLI driver test re-enablement (#25001). (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: merge Created 5 years 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 | pkg/analyzer_cli/test/all.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer_cli/lib/src/options.dart
diff --git a/pkg/analyzer_cli/lib/src/options.dart b/pkg/analyzer_cli/lib/src/options.dart
index ee683e2d084e7eb1a190f6aa8a6ff833fa297fc3..7da6bb41e0ca0edbded103493cf6016572603cfe 100644
--- a/pkg/analyzer_cli/lib/src/options.dart
+++ b/pkg/analyzer_cli/lib/src/options.dart
@@ -17,7 +17,7 @@ const _binaryName = 'dartanalyzer';
/// *Visible for testing.*
ExitHandler exitHandler = exit;
-/// Print the given message to stderr and exit with the given [exitCode]
+/// Print the given [message] to stderr and exit with the given [exitCode].
void printAndFail(String message, {int exitCode: 15}) {
errorSink.writeln(message);
exitHandler(exitCode);
@@ -163,8 +163,9 @@ class CommandLineOptions {
// OK. Report deprecated options.
if (options.enableNullAwareOperators) {
- stderr.writeln(
- "Info: Option '--enable-null-aware-operators' is no longer needed. Null aware operators are supported by default.");
+ errorSink.writeln(
+ "Info: Option '--enable-null-aware-operators' is no longer needed. "
+ "Null aware operators are supported by default.");
}
return options;
@@ -194,11 +195,13 @@ class CommandLineOptions {
..addOption('dart-sdk', help: 'The path to the Dart SDK.')
..addOption('packages',
help:
- 'Path to the package resolution configuration file, which supplies a mapping of package names to paths. This option cannot be used with --package-root.')
+ 'Path to the package resolution configuration file, which supplies '
+ 'a mapping of package names to paths. This option cannot be '
+ 'used with --package-root.')
..addOption('package-root',
abbr: 'p',
- help:
- 'Path to a package root directory (deprecated). This option cannot be used with --packages.')
+ help: 'Path to a package root directory (deprecated). This option '
+ 'cannot be used with --packages.')
..addOption('options', help: 'Path to an analysis options file.')
..addOption('format',
help: 'Specifies the format in which errors are displayed.')
@@ -308,45 +311,50 @@ class CommandLineOptions {
// Help requests.
if (results['help']) {
_showUsage(parser);
- exit(0);
+ exitHandler(0);
+ return null; // Only reachable in testing.
}
// Batch mode and input files.
if (results['batch']) {
if (results.rest.isNotEmpty) {
- stderr.writeln('No source files expected in the batch mode.');
+ errorSink.writeln('No source files expected in the batch mode.');
_showUsage(parser);
- exit(15);
+ exitHandler(15);
+ return null; // Only reachable in testing.
}
} else if (results['version']) {
- print('$_binaryName version ${_getVersion()}');
- exit(0);
+ outSink.write('$_binaryName version ${_getVersion()}');
+ exitHandler(0);
+ return null; // Only reachable in testing.
} else {
if (results.rest.isEmpty) {
_showUsage(parser);
- exit(15);
+ exitHandler(15);
+ return null; // Only reachable in testing.
}
}
return new CommandLineOptions._fromArgs(results, definedVariables);
} on FormatException catch (e) {
- stderr.writeln(e.message);
+ errorSink.writeln(e.message);
_showUsage(parser);
- exit(15);
+ exitHandler(15);
+ return null; // Only reachable in testing.
}
}
static _showUsage(parser) {
- stderr
+ errorSink
.writeln('Usage: $_binaryName [options...] <libraries to analyze...>');
- stderr.writeln(parser.getUsage());
- stderr.writeln('');
- stderr.writeln(
+ errorSink.writeln(parser.getUsage());
+ errorSink.writeln('');
+ errorSink.writeln(
'For more information, see http://www.dartlang.org/tools/analyzer.');
}
}
/// Commandline argument parser.
///
-/// TODO(pquitslund): when the args package supports ignoring unrecognized
+/// TODO(pq): when the args package supports ignoring unrecognized
/// options/flags, this class can be replaced with a simple [ArgParser]
/// instance.
class CommandLineParser {
« no previous file with comments | « no previous file | pkg/analyzer_cli/test/all.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698