rename dartfix "exclude" option to "excludeFix"

This renames the "exclude" option to make it more clear exactly
what is being excluded, similar to the earlier change renaming
"include" to "fix".

Change-Id: I07d164d480c8e389e5c7353db81e7633f0efd3d9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/109921
Reviewed-by: Devon Carew <devoncarew@google.com>
Commit-Queue: Dan Rubel <danrubel@google.com>
This commit is contained in:
Dan Rubel 2019-07-22 20:17:57 +00:00 committed by commit-bot@chromium.org
parent 1e04ff86b0
commit d6c85f4e92
5 changed files with 19 additions and 24 deletions

View file

@ -84,11 +84,11 @@ class Driver {
return true;
}
if (options.excludeFixes.isNotEmpty) {
_unsupportedOption(excludeOption);
_unsupportedOption(excludeFixOption);
return false;
}
if (options.includeFixes.isNotEmpty) {
_unsupportedOption(includeOption);
_unsupportedOption(includeFixOption);
return false;
}
if (options.requiredFixes) {
@ -189,14 +189,14 @@ Analysis Details:
logger.stdout('''
These fixes are automatically applied unless at least one --$includeOption option is specified
(and --$requiredOption is not specified). They may be individually disabled using --$excludeOption.''');
These fixes are automatically applied unless at least one --$includeFixOption option is specified
(and --$requiredOption is not specified). They may be individually disabled using --$excludeFixOption.''');
fixes.where((fix) => fix.isRequired).forEach(showFix);
logger.stdout('''
These fixes are NOT automatically applied, but may be enabled using --$includeOption:''');
These fixes are NOT automatically applied, but may be enabled using --$includeFixOption:''');
fixes.where((fix) => !fix.isRequired).toList()
..sort(compareFixes)

View file

@ -10,8 +10,8 @@ import 'package:dartfix/src/context.dart';
import 'package:path/path.dart' as path;
const forceOption = 'force';
const includeOption = 'fix';
const excludeOption = 'exclude';
const includeFixOption = 'fix';
const excludeFixOption = 'excludeFix';
const overwriteOption = 'overwrite';
const requiredOption = 'required';
@ -44,8 +44,8 @@ class Options {
Options._fromArgs(this.context, ArgResults results)
: force = results[forceOption] as bool,
includeFixes = (results[includeOption] as List ?? []).cast<String>(),
excludeFixes = (results[excludeOption] as List ?? []).cast<String>(),
includeFixes = (results[includeFixOption] as List ?? []).cast<String>(),
excludeFixes = (results[excludeFixOption] as List ?? []).cast<String>(),
overwrite = results[overwriteOption] as bool,
requiredFixes = results[requiredOption] as bool,
sdkPath = _getSdkPath(),
@ -55,9 +55,7 @@ class Options {
useColor = results.wasParsed(_colorOption)
? results[_colorOption] as bool
: null,
verbose = results[_verboseOption] as bool {
includeFixes.addAll((results['include'] as List ?? []).cast<String>());
}
verbose = results[_verboseOption] as bool;
String makeAbsoluteAndNormalize(String target) {
if (!path.isAbsolute(target)) {
@ -69,13 +67,10 @@ class Options {
static Options parse(List<String> args, Context context, Logger logger) {
final parser = ArgParser(allowTrailingOptions: true)
..addSeparator('Choosing fixes to be applied:')
..addMultiOption(includeOption,
..addMultiOption(includeFixOption,
help: 'Include a specific fix.', valueHelp: 'name-of-fix')
// 'include' is an alias for 'fix' (above)
..addMultiOption('include',
help: 'Include a specific fix.', valueHelp: 'name-of-fix', hide: true)
..addMultiOption(excludeOption,
abbr: 'x', help: 'Exclude a specific fix.', valueHelp: 'name-of-fix')
..addMultiOption(excludeFixOption,
help: 'Exclude a specific fix.', valueHelp: 'name-of-fix')
..addFlag(requiredOption,
abbr: 'r',
help: 'Apply required fixes.',
@ -203,7 +198,7 @@ Usage: $_binaryName [options...] <directory paths>
? '''
Use --$_helpOption to display the fixes that can be specified using either
--$includeOption or --$excludeOption.'''
--$includeFixOption or --$excludeFixOption.'''
: '');
}
}

View file

@ -24,7 +24,7 @@ main() {
final testLogger = TestLogger(debug: _debug);
String exampleSource = await exampleFile.readAsString();
var args = ['-xuse-mixin', exampleDir.path];
var args = ['--excludeFix', 'use-mixin', exampleDir.path];
if (_debug) {
args.add('-v');
}

View file

@ -26,7 +26,7 @@ main() {
final errText = testLogger.stderrBuffer.toString();
final outText = testLogger.stdoutBuffer.toString();
expect(errText, isEmpty);
expect(outText, contains('--$excludeOption'));
expect(outText, contains('--$excludeFixOption'));
expect(outText, isNot(contains('Use --help to display the fixes')));
expect(outText, contains('use-mixin'));
});
@ -50,7 +50,7 @@ main() {
print(errText);
print(outText);
expect(errText, isEmpty);
expect(outText, contains('--$excludeOption'));
expect(outText, contains('--$excludeFixOption'));
expect(outText, isNot(contains('Use --help to display the fixes')));
expect(outText, contains('use-mixin'));
});

View file

@ -73,7 +73,7 @@ main() {
}
test('exclude fix', () {
parse(['--exclude', 'c', '--exclude', 'd', 'foo'],
parse(['--excludeFix', 'c', '--excludeFix', 'd', 'foo'],
excludeFixes: ['c', 'd'], targetSuffixes: ['foo']);
});
@ -90,7 +90,7 @@ main() {
});
test('include fix', () {
parse(['--include', 'a', '--include', 'b', 'foo'],
parse(['--fix', 'a', '--fix', 'b', 'foo'],
includeFixes: ['a', 'b'], targetSuffixes: ['foo']);
});