dartfmt
diff --git a/example/test_runner.dart b/example/test_runner.dart
index 0d15e83..d9a6297 100644
--- a/example/test_runner.dart
+++ b/example/test_runner.dart
@@ -20,49 +20,53 @@
abbr: 'c',
defaultsTo: 'none',
help: 'Specify any compilation step (if needed).',
- allowed: ['none', 'dart2js', 'dartc'],
+ allowed: [
+ 'none',
+ 'dart2js',
+ 'dartc'
+ ],
allowedHelp: {
- 'none': 'Do not compile the Dart code (run native Dart code on the'
- ' VM).\n(only valid with the following runtimes: vm, drt)',
- 'dart2js': 'Compile dart code to JavaScript by running dart2js.\n'
- '(only valid with the following runtimes: d8, drt, chrome\n'
- 'safari, ie, firefox, opera, none (compile only))',
- 'dartc': 'Perform static analysis on Dart code by running dartc.\n'
- '(only valid with the following runtimes: none)',
- });
+ 'none': 'Do not compile the Dart code (run native Dart code on the'
+ ' VM).\n(only valid with the following runtimes: vm, drt)',
+ 'dart2js': 'Compile dart code to JavaScript by running dart2js.\n'
+ '(only valid with the following runtimes: d8, drt, chrome\n'
+ 'safari, ie, firefox, opera, none (compile only))',
+ 'dartc': 'Perform static analysis on Dart code by running dartc.\n'
+ '(only valid with the following runtimes: none)',
+ });
parser.addOption('runtime',
abbr: 'r',
defaultsTo: 'vm',
help: 'Where the tests should be run.',
allowed: [
- 'vm',
- 'd8',
- 'drt',
- 'dartium',
- 'ff',
- 'firefox',
- 'chrome',
- 'safari',
- 'ie',
- 'opera',
- 'none'
- ],
+ 'vm',
+ 'd8',
+ 'drt',
+ 'dartium',
+ 'ff',
+ 'firefox',
+ 'chrome',
+ 'safari',
+ 'ie',
+ 'opera',
+ 'none'
+ ],
allowedHelp: {
- 'vm': 'Run Dart code on the standalone dart vm.',
- 'd8': 'Run JavaScript from the command line using v8.',
- // TODO(antonm): rename flag.
- 'drt': 'Run Dart or JavaScript in the headless version of Chrome,\n'
- 'content shell.',
- 'dartium': 'Run Dart or JavaScript in Dartium.',
- 'ff': 'Run JavaScript in Firefox',
- 'chrome': 'Run JavaScript in Chrome',
- 'safari': 'Run JavaScript in Safari',
- 'ie': 'Run JavaScript in Internet Explorer',
- 'opera': 'Run JavaScript in Opera',
- 'none': 'No runtime, compile only (for example, used for dartc static\n'
- 'analysis tests).',
- });
+ 'vm': 'Run Dart code on the standalone dart vm.',
+ 'd8': 'Run JavaScript from the command line using v8.',
+ // TODO(antonm): rename flag.
+ 'drt': 'Run Dart or JavaScript in the headless version of Chrome,\n'
+ 'content shell.',
+ 'dartium': 'Run Dart or JavaScript in Dartium.',
+ 'ff': 'Run JavaScript in Firefox',
+ 'chrome': 'Run JavaScript in Chrome',
+ 'safari': 'Run JavaScript in Safari',
+ 'ie': 'Run JavaScript in Internet Explorer',
+ 'opera': 'Run JavaScript in Opera',
+ 'none': 'No runtime, compile only (for example, used for dartc static\n'
+ 'analysis tests).',
+ });
parser.addOption('arch',
abbr: 'a',
@@ -115,14 +119,14 @@
defaultsTo: 'compact',
help: 'Progress indication mode',
allowed: [
- 'compact',
- 'color',
- 'line',
- 'verbose',
- 'silent',
- 'status',
- 'buildbot'
- ]);
+ 'compact',
+ 'color',
+ 'line',
+ 'verbose',
+ 'silent',
+ 'status',
+ 'buildbot'
+ ]);
parser.addFlag('report',
defaultsTo: false,
@@ -146,7 +150,8 @@
defaultsTo: false,
help: 'Keep the generated files in the temporary directory');
- parser.addOption('special-command', help: """
+ parser.addOption('special-command',
+ help: """
Special command support. Wraps the command line in
a special command. The special command should contain
an '@' character which will be replaced by the normal
diff --git a/lib/command_runner.dart b/lib/command_runner.dart
index 6a6d282..bbf08ae 100644
--- a/lib/command_runner.dart
+++ b/lib/command_runner.dart
@@ -138,7 +138,7 @@
/// command in a block. For example, you might handle the `--verbose` flag
/// here to enable verbose logging before running the command.
///
- /// This returns the return value of [Command.run].
+ /// This returns the return value of [Command.run].
Future<T> runCommand(ArgResults topLevelResults) async {
var argResults = topLevelResults;
var commands = _commands;
@@ -246,6 +246,7 @@
if (parent == null) return _runner;
return parent.runner;
}
+
CommandRunner<T> _runner;
/// The parsed global argument results.
@@ -284,8 +285,8 @@
/// Returns [usage] with [description] removed from the beginning.
String get _usageWithoutDescription {
var buffer = new StringBuffer()
- ..writeln('Usage: $invocation')
- ..writeln(argParser.usage);
+ ..writeln('Usage: $invocation')
+ ..writeln(argParser.usage);
if (_subcommands.isNotEmpty) {
buffer.writeln();
@@ -373,7 +374,7 @@
/// Throws a [UsageException] with [message].
void usageException(String message) =>
- throw new UsageException(message, _usageWithoutDescription);
+ throw new UsageException(message, _usageWithoutDescription);
}
/// Returns a string representation of [commands] fit for use in a usage string.
@@ -384,7 +385,7 @@
{bool isSubcommand: false}) {
// Don't include aliases.
var names =
- commands.keys.where((name) => !commands[name].aliases.contains(name));
+ commands.keys.where((name) => !commands[name].aliases.contains(name));
// Filter out hidden ones, unless they are all hidden.
var visible = names.where((name) => !commands[name].hidden);
@@ -395,7 +396,7 @@
var length = names.map((name) => name.length).reduce(math.max);
var buffer =
- new StringBuffer('Available ${isSubcommand ? "sub" : ""}commands:');
+ new StringBuffer('Available ${isSubcommand ? "sub" : ""}commands:');
for (var name in names) {
var lines = commands[name].summary.split("\n");
buffer.writeln();
diff --git a/lib/src/arg_parser.dart b/lib/src/arg_parser.dart
index fa80031..44ceb64 100644
--- a/lib/src/arg_parser.dart
+++ b/lib/src/arg_parser.dart
@@ -35,9 +35,9 @@
/// after it finds an argument that is neither an option nor a command.
/// This allows options to be specified after regular arguments. Defaults to
/// `false`.
- factory ArgParser({bool allowTrailingOptions: false}) => new ArgParser._(
- <String, Option>{}, <String, ArgParser>{},
- allowTrailingOptions: allowTrailingOptions);
+ factory ArgParser({bool allowTrailingOptions: false}) =>
+ new ArgParser._(<String, Option>{}, <String, ArgParser>{},
+ allowTrailingOptions: allowTrailingOptions);
ArgParser._(Map<String, Option> options, Map<String, ArgParser> commands,
{bool allowTrailingOptions: false})
@@ -45,9 +45,8 @@
this.options = new UnmodifiableMapView(options),
this._commands = commands,
this.commands = new UnmodifiableMapView(commands),
- this.allowTrailingOptions = allowTrailingOptions != null
- ? allowTrailingOptions
- : false;
+ this.allowTrailingOptions =
+ allowTrailingOptions != null ? allowTrailingOptions : false;
/// Defines a command.
///
@@ -69,10 +68,16 @@
///
/// * There is already an option named [name].
/// * There is already an option using abbreviation [abbr].
- void addFlag(String name, {String abbr, String help, bool defaultsTo: false,
- bool negatable: true, void callback(bool value), bool hide: false}) {
+ void addFlag(String name,
+ {String abbr,
+ String help,
+ bool defaultsTo: false,
+ bool negatable: true,
+ void callback(bool value),
+ bool hide: false}) {
_addOption(name, abbr, help, null, null, null, defaultsTo, callback,
- OptionType.FLAG, negatable: negatable, hide: hide);
+ OptionType.FLAG,
+ negatable: negatable, hide: hide);
}
/// Defines a value-taking option. Throws an [ArgumentError] if:
@@ -80,9 +85,16 @@
/// * There is already an option with name [name].
/// * There is already an option using abbreviation [abbr].
/// * [splitCommas] is passed but [allowMultiple] is `false`.
- void addOption(String name, {String abbr, String help, String valueHelp,
- List<String> allowed, Map<String, String> allowedHelp, String defaultsTo,
- void callback(value), bool allowMultiple: false, bool splitCommas,
+ void addOption(String name,
+ {String abbr,
+ String help,
+ String valueHelp,
+ List<String> allowed,
+ Map<String, String> allowedHelp,
+ String defaultsTo,
+ void callback(value),
+ bool allowMultiple: false,
+ bool splitCommas,
bool hide: false}) {
if (!allowMultiple && splitCommas != null) {
throw new ArgumentError(
@@ -94,10 +106,19 @@
splitCommas: splitCommas, hide: hide);
}
- void _addOption(String name, String abbr, String help, String valueHelp,
- List<String> allowed, Map<String, String> allowedHelp, defaultsTo,
- void callback(value), OptionType type,
- {bool negatable: false, bool splitCommas, bool hide: false}) {
+ void _addOption(
+ String name,
+ String abbr,
+ String help,
+ String valueHelp,
+ List<String> allowed,
+ Map<String, String> allowedHelp,
+ defaultsTo,
+ void callback(value),
+ OptionType type,
+ {bool negatable: false,
+ bool splitCommas,
+ bool hide: false}) {
// Make sure the name isn't in use.
if (_options.containsKey(name)) {
throw new ArgumentError('Duplicate option "$name".');
@@ -112,8 +133,8 @@
}
}
- var option = newOption(name, abbr, help, valueHelp, allowed,
- allowedHelp, defaultsTo, callback, type,
+ var option = newOption(name, abbr, help, valueHelp, allowed, allowedHelp,
+ defaultsTo, callback, type,
negatable: negatable, splitCommas: splitCommas, hide: hide);
_options[name] = option;
_optionsAndSeparators.add(option);
diff --git a/lib/src/arg_parser_exception.dart b/lib/src/arg_parser_exception.dart
index 20eddb9..f4129d6 100644
--- a/lib/src/arg_parser_exception.dart
+++ b/lib/src/arg_parser_exception.dart
@@ -10,8 +10,7 @@
final List<String> commands;
ArgParserException(String message, [Iterable<String> commands])
- : commands = commands == null
- ? const []
- : new List.unmodifiable(commands),
+ : commands =
+ commands == null ? const [] : new List.unmodifiable(commands),
super(message);
}
diff --git a/lib/src/arg_results.dart b/lib/src/arg_results.dart
index 50e85fa..20349da 100644
--- a/lib/src/arg_results.dart
+++ b/lib/src/arg_results.dart
@@ -10,8 +10,12 @@
///
/// Since [ArgResults] doesn't have a public constructor, this lets [Parser]
/// get to it. This function isn't exported to the public API of the package.
-ArgResults newArgResults(ArgParser parser, Map<String, dynamic> parsed,
- String name, ArgResults command, List<String> rest,
+ArgResults newArgResults(
+ ArgParser parser,
+ Map<String, dynamic> parsed,
+ String name,
+ ArgResults command,
+ List<String> rest,
List<String> arguments) {
return new ArgResults._(parser, parsed, name, command, rest, arguments);
}
diff --git a/lib/src/option.dart b/lib/src/option.dart
index a37193f..5eb0efb 100644
--- a/lib/src/option.dart
+++ b/lib/src/option.dart
@@ -8,13 +8,22 @@
///
/// Since [Option] doesn't have a public constructor, this lets [ArgParser]
/// get to it. This function isn't exported to the public API of the package.
-Option newOption(String name, String abbreviation, String help,
- String valueHelp, List<String> allowed, Map<String, String> allowedHelp,
- defaultValue, Function callback, OptionType type,
- {bool negatable, bool splitCommas, bool hide: false}) {
+Option newOption(
+ String name,
+ String abbreviation,
+ String help,
+ String valueHelp,
+ List<String> allowed,
+ Map<String, String> allowedHelp,
+ defaultValue,
+ Function callback,
+ OptionType type,
+ {bool negatable,
+ bool splitCommas,
+ bool hide: false}) {
return new Option._(name, abbreviation, help, valueHelp, allowed, allowedHelp,
- defaultValue, callback, type, negatable: negatable,
- splitCommas: splitCommas, hide: hide);
+ defaultValue, callback, type,
+ negatable: negatable, splitCommas: splitCommas, hide: hide);
}
/// A command-line option. Includes both flags and options which take a value.
@@ -41,22 +50,28 @@
/// Whether the option allows multiple values.
bool get isMultiple => type == OptionType.MULTIPLE;
- Option._(this.name, this.abbreviation, this.help, this.valueHelp,
- List<String> allowed, Map<String, String> allowedHelp, this.defaultValue,
- this.callback, OptionType type, {this.negatable, bool splitCommas,
+ Option._(
+ this.name,
+ this.abbreviation,
+ this.help,
+ this.valueHelp,
+ List<String> allowed,
+ Map<String, String> allowedHelp,
+ this.defaultValue,
+ this.callback,
+ OptionType type,
+ {this.negatable,
+ bool splitCommas,
this.hide: false})
- : this.allowed = allowed == null
- ? null
- : new UnmodifiableListView(allowed),
- this.allowedHelp = allowedHelp == null
- ? null
- : new UnmodifiableMapView(allowedHelp),
+ : this.allowed =
+ allowed == null ? null : new UnmodifiableListView(allowed),
+ this.allowedHelp =
+ allowedHelp == null ? null : new UnmodifiableMapView(allowedHelp),
this.type = type,
// If the user doesn't specify [splitCommas], it defaults to true for
// multiple options.
- this.splitCommas = splitCommas == null
- ? type == OptionType.MULTIPLE
- : splitCommas {
+ this.splitCommas =
+ splitCommas == null ? type == OptionType.MULTIPLE : splitCommas {
if (name.isEmpty) {
throw new ArgumentError('Name cannot be empty.');
} else if (name.startsWith('-')) {
diff --git a/lib/src/parser.dart b/lib/src/parser.dart
index 64374fc..6c2ee40 100644
--- a/lib/src/parser.dart
+++ b/lib/src/parser.dart
@@ -70,8 +70,7 @@
} on ArgParserException catch (error) {
if (commandName == null) rethrow;
throw new ArgParserException(
- error.message,
- [commandName]..addAll(error.commands));
+ error.message, [commandName]..addAll(error.commands));
}
// All remaining arguments were passed to command so clear them here.
@@ -167,7 +166,8 @@
} else {
// If we got some non-flag characters, then it must be a value, but
// if we got here, it's a flag, which is wrong.
- validate(abbrOpt[2] == '',
+ validate(
+ abbrOpt[2] == '',
'Option "-$c" is a flag and cannot handle value '
'"${abbrOpt[1].substring(1)}${abbrOpt[2]}".');
diff --git a/test/args_test.dart b/test/args_test.dart
index 4553b30..ff968ad 100644
--- a/test/args_test.dart
+++ b/test/args_test.dart
@@ -26,7 +26,8 @@
throwsIllegalArg(() => parser.addFlag('flummox', abbr: 'f'));
});
- test('throws ArgumentError if the abbreviation is longer '
+ test(
+ 'throws ArgumentError if the abbreviation is longer '
'than one character', () {
var parser = new ArgParser();
throwsIllegalArg(() => parser.addFlag('flummox', abbr: 'flu'));
@@ -70,7 +71,8 @@
throwsIllegalArg(() => parser.addOption('flummox', abbr: 'f'));
});
- test('throws ArgumentError if the abbreviation is longer '
+ test(
+ 'throws ArgumentError if the abbreviation is longer '
'than one character', () {
var parser = new ArgParser();
throwsIllegalArg(() => parser.addOption('flummox', abbr: 'flu'));
@@ -107,7 +109,8 @@
}
});
- test('throws ArgumentError if splitCommas is passed with allowMultiple: '
+ test(
+ 'throws ArgumentError if splitCommas is passed with allowMultiple: '
'false', () {
var parser = new ArgParser();
throwsIllegalArg(() => parser.addOption('flummox', splitCommas: true));
diff --git a/test/command_runner_test.dart b/test/command_runner_test.dart
index 9b0713a..5a765b1 100644
--- a/test/command_runner_test.dart
+++ b/test/command_runner_test.dart
@@ -147,18 +147,22 @@
var command = new FooCommand();
runner.addCommand(command);
- expect(runner.run(["foo"]).then((_) {
- expect(command.hasRun, isTrue);
- }), completes);
+ expect(
+ runner.run(["foo"]).then((_) {
+ expect(command.hasRun, isTrue);
+ }),
+ completes);
});
test("runs an asynchronous command", () {
var command = new AsyncCommand();
runner.addCommand(command);
- expect(runner.run(["async"]).then((_) {
- expect(command.hasRun, isTrue);
- }), completes);
+ expect(
+ runner.run(["async"]).then((_) {
+ expect(command.hasRun, isTrue);
+ }),
+ completes);
});
test("runs a command with a return value", () {
@@ -181,27 +185,33 @@
var command = new HiddenCommand();
runner.addCommand(command);
- expect(runner.run(["hidden"]).then((_) {
- expect(command.hasRun, isTrue);
- }), completes);
+ expect(
+ runner.run(["hidden"]).then((_) {
+ expect(command.hasRun, isTrue);
+ }),
+ completes);
});
test("runs an aliased comand", () {
var command = new AliasedCommand();
runner.addCommand(command);
- expect(runner.run(["als"]).then((_) {
- expect(command.hasRun, isTrue);
- }), completes);
+ expect(
+ runner.run(["als"]).then((_) {
+ expect(command.hasRun, isTrue);
+ }),
+ completes);
});
test("runs a subcommand", () {
var command = new AsyncCommand();
runner.addCommand(new FooCommand()..addSubcommand(command));
- expect(runner.run(["foo", "async"]).then((_) {
- expect(command.hasRun, isTrue);
- }), completes);
+ expect(
+ runner.run(["foo", "async"]).then((_) {
+ expect(command.hasRun, isTrue);
+ }),
+ completes);
});
group("with --help", () {
@@ -279,18 +289,21 @@
group("with an invalid argument", () {
test("at the root throws the root usage", () {
- expect(runner.run(["--asdf"]), throwsUsageException(
- 'Could not find an option named "asdf".',
- '$_DEFAULT_USAGE'));
+ expect(
+ runner.run(["--asdf"]),
+ throwsUsageException(
+ 'Could not find an option named "asdf".', '$_DEFAULT_USAGE'));
});
test("for a command throws the command usage", () {
var command = new FooCommand();
runner.addCommand(command);
- expect(runner.run(["foo", "--asdf"]), throwsUsageException(
- 'Could not find an option named "asdf".',
- """
+ expect(
+ runner.run(["foo", "--asdf"]),
+ throwsUsageException(
+ 'Could not find an option named "asdf".',
+ """
Usage: test foo [arguments]
-h, --help Print this usage information.
@@ -313,28 +326,36 @@
});
test("includes the footer in usage errors", () {
- expect(runner.run(["--bad"]), throwsUsageException(
- 'Could not find an option named "bad".',
- "$_DEFAULT_USAGE\nAlso, footer!"));
+ expect(
+ runner.run(["--bad"]),
+ throwsUsageException('Could not find an option named "bad".',
+ "$_DEFAULT_USAGE\nAlso, footer!"));
});
});
group("throws a useful error when", () {
test("arg parsing fails", () {
- expect(runner.run(["--bad"]), throwsUsageException(
- 'Could not find an option named "bad".', _DEFAULT_USAGE));
+ expect(
+ runner.run(["--bad"]),
+ throwsUsageException(
+ 'Could not find an option named "bad".', _DEFAULT_USAGE));
});
test("a top-level command doesn't exist", () {
- expect(runner.run(["bad"]), throwsUsageException(
- 'Could not find a command named "bad".', _DEFAULT_USAGE));
+ expect(
+ runner.run(["bad"]),
+ throwsUsageException(
+ 'Could not find a command named "bad".', _DEFAULT_USAGE));
});
test("a subcommand doesn't exist", () {
runner.addCommand(new FooCommand()..addSubcommand(new AsyncCommand()));
- expect(runner.run(["foo bad"]), throwsUsageException(
- 'Could not find a command named "foo bad".', """
+ expect(
+ runner.run(["foo bad"]),
+ throwsUsageException(
+ 'Could not find a command named "foo bad".',
+ """
Usage: test <command> [arguments]
Global options:
@@ -350,8 +371,11 @@
test("a subcommand wasn't passed", () {
runner.addCommand(new FooCommand()..addSubcommand(new AsyncCommand()));
- expect(runner.run(["foo"]), throwsUsageException(
- 'Missing subcommand for "test foo".', """
+ expect(
+ runner.run(["foo"]),
+ throwsUsageException(
+ 'Missing subcommand for "test foo".',
+ """
Usage: test foo <subcommand> [arguments]
-h, --help Print this usage information.
@@ -364,8 +388,11 @@
test("a command that doesn't take arguments was given them", () {
runner.addCommand(new FooCommand());
- expect(runner.run(["foo", "bar"]), throwsUsageException(
- 'Command "foo" does not take any arguments.', """
+ expect(
+ runner.run(["foo", "bar"]),
+ throwsUsageException(
+ 'Command "foo" does not take any arguments.',
+ """
Usage: test foo [arguments]
-h, --help Print this usage information.
diff --git a/test/command_test.dart b/test/command_test.dart
index cd32c63..c0c08d3 100644
--- a/test/command_test.dart
+++ b/test/command_test.dart
@@ -90,8 +90,11 @@
});
test("usageException splits up the message and usage", () {
- expect(() => foo.usageException("message"),
- throwsUsageException("message", """
+ expect(
+ () => foo.usageException("message"),
+ throwsUsageException(
+ "message",
+ """
Usage: test foo [arguments]
-h, --help Print this usage information.
diff --git a/test/parse_test.dart b/test/parse_test.dart
index 6ce8a19..b163862 100644
--- a/test/parse_test.dart
+++ b/test/parse_test.dart
@@ -152,7 +152,8 @@
expect(a, isNull);
});
- test('for multiple present, allowMultiple, options are invoked with '
+ test(
+ 'for multiple present, allowMultiple, options are invoked with '
'value as a list', () {
var a;
var parser = new ArgParser();
@@ -167,7 +168,8 @@
expect(a, new isInstanceOf<List<String>>());
});
- test('for single present, allowMultiple, options are invoked with '
+ test(
+ 'for single present, allowMultiple, options are invoked with '
' value as a single element list', () {
var a;
var parser = new ArgParser();
@@ -178,7 +180,8 @@
expect(a, equals(['v']));
});
- test('for absent, allowMultiple, options are invoked with default '
+ test(
+ 'for absent, allowMultiple, options are invoked with default '
'value as a list.', () {
var a;
var parser = new ArgParser();
@@ -191,7 +194,8 @@
expect(a, equals(['v']));
});
- test('for absent, allowMultiple, options are invoked with value '
+ test(
+ 'for absent, allowMultiple, options are invoked with value '
'as an empty list.', () {
var a;
var parser = new ArgParser();
@@ -212,7 +216,8 @@
expect(a, equals(['v', 'w', 'x']));
});
- test("allowMultiple doesn't parses comma-separated strings with "
+ test(
+ "allowMultiple doesn't parses comma-separated strings with "
"splitCommas: false", () {
var a;
var parser = new ArgParser();
@@ -337,8 +342,8 @@
test('throw if a comma-separated value is not allowed', () {
var parser = new ArgParser();
- parser.addOption('mode', abbr: 'm', allowMultiple: true,
- allowed: ['debug', 'release']);
+ parser.addOption('mode',
+ abbr: 'm', allowMultiple: true, allowed: ['debug', 'release']);
throwsFormat(parser, ['-mdebug,profile']);
});
@@ -418,8 +423,8 @@
parser.addOption('other');
expect(parser.parse(['--mode', '--other'])['mode'], equals('--other'));
- expect(parser.parse(['--mode', '--unknown'])['mode'],
- equals('--unknown'));
+ expect(
+ parser.parse(['--mode', '--unknown'])['mode'], equals('--unknown'));
expect(parser.parse(['--mode', '-abbr'])['mode'], equals('-abbr'));
expect(parser.parse(['--mode', '--'])['mode'], equals('--'));
});
@@ -453,7 +458,8 @@
expect(args['define'], equals(['1', '2']));
});
- test('returns the default value for multi-valued arguments '
+ test(
+ 'returns the default value for multi-valued arguments '
'if not explicitly set', () {
var parser = new ArgParser();
parser.addOption('define', defaultsTo: '0', allowMultiple: true);
diff --git a/test/usage_test.dart b/test/usage_test.dart
index 31c19d2..6c591bf 100644
--- a/test/usage_test.dart
+++ b/test/usage_test.dart
@@ -11,7 +11,9 @@
var parser = new ArgParser();
parser.addFlag('mode', help: 'The mode');
- validateUsage(parser, '''
+ validateUsage(
+ parser,
+ '''
--[no-]mode The mode
''');
});
@@ -20,7 +22,9 @@
var parser = new ArgParser();
parser.addFlag('mode', negatable: false, help: 'The mode');
- validateUsage(parser, '''
+ validateUsage(
+ parser,
+ '''
--mode The mode
''');
});
@@ -29,7 +33,9 @@
var parser = new ArgParser();
parser.addFlag('mode', help: 'The mode');
- validateUsage(parser, '''
+ validateUsage(
+ parser,
+ '''
--[no-]mode The mode
''');
});
@@ -39,7 +45,9 @@
parser.addFlag('mode', abbr: 'm', help: 'The mode');
parser.addOption('long', help: 'Lacks an abbreviation');
- validateUsage(parser, '''
+ validateUsage(
+ parser,
+ '''
-m, --[no-]mode The mode
--long Lacks an abbreviation
''');
@@ -50,7 +58,9 @@
parser.addFlag('mode', abbr: 'm', help: 'Lined up with below');
parser.addOption('a-really-long-name', help: 'Its help text');
- validateUsage(parser, '''
+ validateUsage(
+ parser,
+ '''
-m, --[no-]mode Lined up with below
--a-really-long-name Its help text
''');
@@ -60,7 +70,9 @@
var parser = new ArgParser();
parser.addFlag('mode', help: '\n\n\n\nAfter newlines');
- validateUsage(parser, '''
+ validateUsage(
+ parser,
+ '''
--[no-]mode After newlines
''');
});
@@ -69,7 +81,9 @@
var parser = new ArgParser();
parser.addFlag('mode', help: 'Before newlines\n\n\n\n');
- validateUsage(parser, '''
+ validateUsage(
+ parser,
+ '''
--[no-]mode Before newlines
''');
});
@@ -80,7 +94,9 @@
parser.addFlag('monkey', help: 'Second');
parser.addFlag('wombat', help: 'Third');
- validateUsage(parser, '''
+ validateUsage(
+ parser,
+ '''
--[no-]zebra First
--[no-]monkey Second
--[no-]wombat Third
@@ -92,7 +108,9 @@
parser.addFlag('affirm', help: 'Should be on', defaultsTo: true);
parser.addFlag('negate', help: 'Should be off', defaultsTo: false);
- validateUsage(parser, '''
+ validateUsage(
+ parser,
+ '''
--[no-]affirm Should be on
(defaults to on)
@@ -104,7 +122,9 @@
var parser = new ArgParser();
parser.addOption('any', help: 'Can be anything', defaultsTo: 'whatevs');
- validateUsage(parser, '''
+ validateUsage(
+ parser,
+ '''
--any Can be anything
(defaults to "whatevs")
''');
@@ -115,7 +135,9 @@
parser.addOption('out',
abbr: 'o', help: 'Where to write file', valueHelp: 'path');
- validateUsage(parser, '''
+ validateUsage(
+ parser,
+ '''
-o, --out=<path> Where to write file
''');
});
@@ -126,7 +148,9 @@
help: 'Like in cards',
allowed: ['spades', 'clubs', 'hearts', 'diamonds']);
- validateUsage(parser, '''
+ validateUsage(
+ parser,
+ '''
--suit Like in cards
[spades, clubs, hearts, diamonds]
''');
@@ -139,7 +163,9 @@
defaultsTo: 'clubs',
allowed: ['spades', 'clubs', 'hearts', 'diamonds']);
- validateUsage(parser, '''
+ validateUsage(
+ parser,
+ '''
--suit Like in cards
[spades, clubs (default), hearts, diamonds]
''');
@@ -150,15 +176,22 @@
parser.addOption('suit',
help: 'Like in cards',
defaultsTo: 'clubs',
- allowed: ['spades', 'clubs', 'diamonds', 'hearts'],
+ allowed: [
+ 'spades',
+ 'clubs',
+ 'diamonds',
+ 'hearts'
+ ],
allowedHelp: {
- 'spades': 'Swords of a soldier',
- 'clubs': 'Weapons of war',
- 'diamonds': 'Money for this art',
- 'hearts': 'The shape of my heart'
- });
+ 'spades': 'Swords of a soldier',
+ 'clubs': 'Weapons of war',
+ 'diamonds': 'Money for this art',
+ 'hearts': 'The shape of my heart'
+ });
- validateUsage(parser, '''
+ validateUsage(
+ parser,
+ '''
--suit Like in cards
[clubs] Weapons of war
@@ -174,7 +207,9 @@
parser.addOption('second', hide: true);
parser.addOption('third', help: 'The third option');
- validateUsage(parser, '''
+ validateUsage(
+ parser,
+ '''
--first The first option
--third The third option
''');
@@ -186,7 +221,9 @@
parser.addFlag('second', hide: true);
parser.addFlag('third', help: 'The third flag');
- validateUsage(parser, '''
+ validateUsage(
+ parser,
+ '''
--[no-]first The first flag
--[no-]third The third flag
''');
@@ -198,7 +235,9 @@
parser.addFlag('second-very-long-option', hide: true);
parser.addFlag('third', help: 'The third flag');
- validateUsage(parser, '''
+ validateUsage(
+ parser,
+ '''
--[no-]first The first flag
--[no-]third The third flag
''');
@@ -213,7 +252,9 @@
parser.addSeparator('Marsupial:');
parser.addFlag('wombat', help: 'Third');
- validateUsage(parser, '''
+ validateUsage(
+ parser,
+ '''
--[no-]zebra First
Primate:
@@ -230,7 +271,9 @@
parser.addSeparator('Primate:');
parser.addFlag('monkey', help: 'Second');
- validateUsage(parser, '''
+ validateUsage(
+ parser,
+ '''
--[no-]zebra Multi
line
@@ -244,7 +287,9 @@
parser.addSeparator('Equine:');
parser.addFlag('zebra', help: 'First');
- validateUsage(parser, '''
+ validateUsage(
+ parser,
+ '''
Equine:
--[no-]zebra First
''');
@@ -255,7 +300,9 @@
parser.addFlag('zebra', help: 'First');
parser.addSeparator('Primate:');
- validateUsage(parser, '''
+ validateUsage(
+ parser,
+ '''
--[no-]zebra First
Primate:
@@ -267,7 +314,9 @@
parser.addSeparator('First');
parser.addSeparator('Second');
- validateUsage(parser, '''
+ validateUsage(
+ parser,
+ '''
First
Second