diff --git a/packages/cli_tools/lib/src/better_command_runner/better_command_runner.dart b/packages/cli_tools/lib/src/better_command_runner/better_command_runner.dart index 071412f..7029f03 100644 --- a/packages/cli_tools/lib/src/better_command_runner/better_command_runner.dart +++ b/packages/cli_tools/lib/src/better_command_runner/better_command_runner.dart @@ -183,10 +183,11 @@ class BetterCommandRunner ctx.provider.store(AnalyticsEnabled(analyticsEnabled)); if (analyticsEnabled) { final actionOption = ctx.specifiedActionOptions().firstOrNull; - final commandName = - actionOption?.option.toString() ?? - ctx.next?.command.name ?? - ctx.command.name; + final commandName = actionOption is HelpActionOption + ? BetterCommandRunnerAnalyticsEvents.help + : actionOption?.option.toString() ?? + ctx.next?.command.name ?? + ctx.command.name; return sendAnalyticsEvent( ctx, commandName, diff --git a/packages/cli_tools/test/better_command_runner/analytics_test.dart b/packages/cli_tools/test/better_command_runner/analytics_test.dart index fe7c6af..1a404e8 100644 --- a/packages/cli_tools/test/better_command_runner/analytics_test.dart +++ b/packages/cli_tools/test/better_command_runner/analytics_test.dart @@ -227,7 +227,10 @@ void main() { await flushEventQueue(); expect(events, hasLength(1)); - expect(events.first, equals('help')); + expect( + events.first, + equals(BetterCommandRunnerAnalyticsEvents.help), + ); }, ); }); diff --git a/packages/cli_tools/test/better_command_runner/better_command_test.dart b/packages/cli_tools/test/better_command_runner/better_command_test.dart index bacad3b..2b3cb21 100644 --- a/packages/cli_tools/test/better_command_runner/better_command_test.dart +++ b/packages/cli_tools/test/better_command_runner/better_command_test.dart @@ -99,7 +99,10 @@ void main() { await Future.delayed(const Duration(milliseconds: 100)); expect(analyticsEvents, hasLength(1)); - expect(analyticsEvents.single, 'help'); + expect( + analyticsEvents.single, + BetterCommandRunnerAnalyticsEvents.help, + ); }); test('when running with subcommand `help` ' diff --git a/packages/cli_tools/test/better_command_runner/logging_test.dart b/packages/cli_tools/test/better_command_runner/logging_test.dart index 1afa6d6..d5acbd6 100644 --- a/packages/cli_tools/test/better_command_runner/logging_test.dart +++ b/packages/cli_tools/test/better_command_runner/logging_test.dart @@ -101,7 +101,7 @@ void main() { 'then option name is mandatory message is logged to error.', () async { expect(errors, hasLength(1)); - expect(errors.first, contains('Option `name` is mandatory')); + expect(errors.first, contains('Option "--name" is mandatory')); }, ); }); diff --git a/packages/config/lib/src/command/completion/completion_command.dart b/packages/config/lib/src/command/completion/completion_command.dart index 143e285..bc77b9b 100644 --- a/packages/config/lib/src/command/completion/completion_command.dart +++ b/packages/config/lib/src/command/completion/completion_command.dart @@ -105,10 +105,10 @@ class CompletionCommand extends Command { 'The script needs to be installed only once: it asks ' '$_executableName for the completion alternatives, so it keeps ' 'up automatically when $_executableName is updated.\n\n' - 'To install it, run `$_executableName completion install`.\n\n' + 'To install it, run "$_executableName completion install".\n\n' '${completionInstallationOverview(_executableName, heading: 'Manual installation:')}\n\n' 'For a wrapper script with name , generate or install ' - 'the script with `--command `.', + 'the script with "--command ".', hidden: _hidden, ); diff --git a/packages/config/lib/src/command/completion/completion_engine.dart b/packages/config/lib/src/command/completion/completion_engine.dart index cbbea0c..fa05011 100644 --- a/packages/config/lib/src/command/completion/completion_engine.dart +++ b/packages/config/lib/src/command/completion/completion_engine.dart @@ -572,7 +572,7 @@ class _ChainParsedArgs implements ParsedArgs { final value = result.flagOptions[option]; if (value != null) return value; } - throw StateError('Flag ${option.argName} not found'); + throw StateError('Flag $option not found'); } @override @@ -581,7 +581,7 @@ class _ChainParsedArgs implements ParsedArgs { final value = result.regularOptions[option]; if (value != null && _wasTyped(value)) return value; } - throw StateError('Option ${option.argName} not found'); + throw StateError('Option $option not found'); } @override @@ -594,7 +594,7 @@ class _ChainParsedArgs implements ParsedArgs { .toList(); } } - throw StateError('Multi-option ${option.argName} not found'); + throw StateError('Multi-option $option not found'); } @override diff --git a/packages/config/lib/src/config/arg_parser/parser.dart b/packages/config/lib/src/config/arg_parser/parser.dart index cf72fac..5db8718 100644 --- a/packages/config/lib/src/config/arg_parser/parser.dart +++ b/packages/config/lib/src/config/arg_parser/parser.dart @@ -581,7 +581,7 @@ void _rejectSubcommandSpelling( final kind = isAlias ? 'alias' : 'name'; throw CommandDefinitionError( subcommand, - 'Subcommand $kind `$spelling` collides with ${option.option.qualifiedString()} ' + 'Subcommand $kind "$spelling" collides with ${option.option.qualifiedString()} ' 'for command $commandName', ); } diff --git a/packages/config/lib/src/config/arg_parser_bridge.dart b/packages/config/lib/src/config/arg_parser_bridge.dart index 0b27c3e..7afdd5a 100644 --- a/packages/config/lib/src/config/arg_parser_bridge.dart +++ b/packages/config/lib/src/config/arg_parser_bridge.dart @@ -61,7 +61,7 @@ class OldParsedArgs implements ParsedArgs { String _optionArgName(final OptionDefinition option) { final argName = option.option.argName; if (argName == null) { - throw StateError('Option has no arg name: $option'); + throw StateError('Option has no arg name: ${option.option}'); } return argName; } diff --git a/packages/config/lib/src/config/arg_parser_facade.dart b/packages/config/lib/src/config/arg_parser_facade.dart index ed9a0ae..22f2309 100644 --- a/packages/config/lib/src/config/arg_parser_facade.dart +++ b/packages/config/lib/src/config/arg_parser_facade.dart @@ -101,7 +101,7 @@ class NewParsedArgs implements ParsedArgs { bool flag(final FlagOption option) { final value = _result.flagOptions[option]; if (value == null) { - throw StateError('Flag ${option.option.argName} not found'); + throw StateError('Flag ${option.option} not found'); } return value; } @@ -110,7 +110,7 @@ class NewParsedArgs implements ParsedArgs { String option(final OptionDefinition option) { final value = _result.regularOptions[option]; if (value == null) { - throw StateError('Option ${option.option.argName} not found'); + throw StateError('Option ${option.option} not found'); } return value; } @@ -119,7 +119,7 @@ class NewParsedArgs implements ParsedArgs { List multiOption(final MultiOption option) { final value = _result.multiOptions[option]; if (value == null) { - throw StateError('Multi-option ${option.option.argName} not found'); + throw StateError('Multi-option ${option.option} not found'); } return value; } diff --git a/packages/config/lib/src/config/exceptions.dart b/packages/config/lib/src/config/exceptions.dart index 903c99a..b59ed39 100644 --- a/packages/config/lib/src/config/exceptions.dart +++ b/packages/config/lib/src/config/exceptions.dart @@ -31,7 +31,7 @@ class CommandDefinitionError extends ConfigDefinitionError { @override String toString() { - final label = 'command `${command.name}`'; + final label = 'command "${command.name}"'; return message != null ? '$runtimeType: Invalid definition for $label: $message' : '$runtimeType: Invalid definition for $label'; diff --git a/packages/config/lib/src/config/options.dart b/packages/config/lib/src/config/options.dart index a54eee3..5919d2e 100644 --- a/packages/config/lib/src/config/options.dart +++ b/packages/config/lib/src/config/options.dart @@ -430,21 +430,26 @@ abstract class ConfigOptionBase implements OptionDefinition { ]; } - // TODO: Present arg options including the '--' prefix, - // and {position 0} for positional arguments without a name. @override - String toString() => argName ?? envName ?? ''; + String toString() => _argString ?? envName ?? _unnamedOptionString; + + String? get _argString => argName != null + ? '--$argName' + : argPos != null + ? '{$argPos}' + : null; String qualifiedString() { if (argName != null) { - return V is bool ? 'flag `$argName`' : 'option `$argName`'; + final kind = this is ConfigOptionBase ? 'flag' : 'option'; + return '$kind "--$argName"'; + } + if (argPos != null) { + return 'positional argument {$argPos}'; } if (envName != null) { return 'environment variable `$envName`'; } - if (argPos != null) { - return 'positional argument $argPos'; - } final keys = allConfigKeys; if (keys.isNotEmpty) { if (keys.length == 1) { @@ -914,7 +919,7 @@ List validateOptions( if (argPosOpts.containsKey(opt.option.argPos)) { throw OptionDefinitionError( opt, - 'Duplicate argument position: ${opt.option.argPos} for $opt', + 'Duplicate argument position: ${opt.option.argPos} for ${opt.option}', ); } argPosOpts[argPos] = opt; @@ -925,7 +930,7 @@ List validateOptions( if (envNameOpts.containsKey(opt.option.envName)) { throw OptionDefinitionError( opt, - 'Duplicate environment variable name: ${opt.option.envName} for $opt', + 'Duplicate environment variable name: ${opt.option.envName} for ${opt.option}', ); } envNameOpts[envName] = opt; @@ -980,7 +985,7 @@ void _claimOptionArgs( names, argName, opt, - 'Duplicate argument name: $argName for $opt', + 'Duplicate argument name: "$argName" of ${opt.option}', ); if (opt.option case final FlagOption flag when flag.negatable) { final negation = 'no-$argName'; @@ -988,7 +993,7 @@ void _claimOptionArgs( names, negation, opt, - 'Duplicate argument name: $negation for $opt', + 'Duplicate argument name: "$negation" of ${opt.option}', ); } @@ -998,7 +1003,7 @@ void _claimOptionArgs( names, alias, opt, - 'Duplicate argument name: $alias for $opt', + 'Duplicate argument name: alias "$alias" of ${opt.option}', ); } } @@ -1008,7 +1013,7 @@ void _claimOptionArgs( abbrevs, abbrev, opt, - 'Duplicate argument abbreviation: $abbrev for $opt', + 'Duplicate argument abbreviation: "$abbrev" of ${opt.option}', ); } } diff --git a/packages/config/test/command/command_run_context_test.dart b/packages/config/test/command/command_run_context_test.dart index 84b4f31..37f2fd7 100644 --- a/packages/config/test/command/command_run_context_test.dart +++ b/packages/config/test/command/command_run_context_test.dart @@ -202,7 +202,7 @@ void main() { }); test('when the option is omitted then the missing option is reported', () { - expect(error?.message, 'greet: Option `name` is mandatory.'); + expect(error?.message, 'greet: Option "--name" is mandatory.'); }); test( @@ -253,7 +253,7 @@ void main() { expect( error?.message, 'greet: Unknown option: --missing.\n' - 'greet: Option `name` is mandatory.', + 'greet: Option "--name" is mandatory.', ); }, ); @@ -288,8 +288,8 @@ void main() { test('when both options are omitted then both errors are reported', () { expect( error?.message, - 'greet: Option `name` is mandatory.\n' - 'greet: Option `target` is mandatory.', + 'greet: Option "--name" is mandatory.\n' + 'greet: Option "--target" is mandatory.', ); }); }); @@ -343,8 +343,8 @@ void main() { () { expect( error?.message, - 'tool: Option `verbose` is mandatory.\n' - 'greet: Option `name` is mandatory.', + 'tool: Option "--verbose" is mandatory.\n' + 'greet: Option "--name" is mandatory.', ); }, ); @@ -789,8 +789,8 @@ void main() { test('when the variable is not allowed then the value is reported', () { expect( error?.message, - 'greet: Invalid value for option `user`: ' - '`nope` is not an allowed value for option `user`.', + 'greet: Invalid value for option "--user": ' + '`nope` is not an allowed value for option "--user"', ); }); @@ -883,7 +883,7 @@ void main() { () { expect( error?.message, - 'greet: Option `jobs` value true is of type bool, not int.', + 'greet: Option "--jobs" value true is of type bool, not int.', ); }, ); diff --git a/packages/config/test/command/command_validation_test.dart b/packages/config/test/command/command_validation_test.dart index 8348b29..3b665a6 100644 --- a/packages/config/test/command/command_validation_test.dart +++ b/packages/config/test/command/command_validation_test.dart @@ -71,7 +71,7 @@ void main() { test('then the duplicate command name is reported', () { expect( error.toString(), - 'CommandDefinitionError: Invalid definition for command `build`: ' + 'CommandDefinitionError: Invalid definition for command "build": ' 'Duplicate subcommand name: build for command tool', ); }); @@ -138,9 +138,9 @@ void main() { isA().having( (final error) => error.toString(), 'toString', - 'CommandDefinitionError: Invalid definition for command `build`: ' + 'CommandDefinitionError: Invalid definition for command "build": ' 'Cannot define positional options on a command with subcommands: ' - 'option `file`.', + 'option "--file".', ), ); }); @@ -200,8 +200,8 @@ void main() { isA().having( (final error) => error.toString(), 'toString', - 'OptionDefinitionError: Invalid definition for option `target`: ' - 'Duplicate argument name: target for target', + 'OptionDefinitionError: Invalid definition for option "--target": ' + 'Duplicate argument name: "target" of --target', ), ); }); diff --git a/packages/config/test/command/completion/completion_command_test.dart b/packages/config/test/command/completion/completion_command_test.dart index dab7821..62adf3b 100644 --- a/packages/config/test/command/completion/completion_command_test.dart +++ b/packages/config/test/command/completion/completion_command_test.dart @@ -140,7 +140,7 @@ void main() { 'then the install subcommand is described and listed', () async { await runner.run(['completion', '--help']); final output = out.toString(); - expect(output, contains('run `comptool completion install`')); + expect(output, contains('run "comptool completion install"')); expect( output, matches(RegExp(r'install +Install the shell completion script')), @@ -766,7 +766,7 @@ void main() { 'message', allOf( contains('Missing value for option: --completion'), - contains('`target` is mandatory'), + contains('"--target" is mandatory'), ), ), ), @@ -783,7 +783,7 @@ void main() { (final e) => e.message, 'message', allOf( - contains('Invalid value for option `completion`: ""'), + contains('Invalid value for option "--completion": ""'), contains('bash|zsh|fish|powershell|carapace'), ), ), @@ -799,7 +799,7 @@ void main() { isA().having( (final e) => e.message, 'message', - contains('Invalid value for option `completion`: "ksh"'), + contains('Invalid value for option "--completion": "ksh"'), ), ), ); @@ -814,7 +814,7 @@ void main() { (final e) => e.message, 'message', contains( - 'Invalid value for option `completion`: "ksh" ' + 'Invalid value for option "--completion": "ksh" ' 'is not in bash|zsh|fish|powershell|carapace', ), ), @@ -832,7 +832,7 @@ void main() { isA().having( (final e) => e.message, 'message', - contains('Invalid value for option `completion`: "Bash"'), + contains('Invalid value for option "--completion": "Bash"'), ), ), ); diff --git a/packages/config/test/command/help_command_test.dart b/packages/config/test/command/help_command_test.dart index c0f0eba..cdb9040 100644 --- a/packages/config/test/command/help_command_test.dart +++ b/packages/config/test/command/help_command_test.dart @@ -528,12 +528,12 @@ void main() { 'along with the usage', () { expect( error?.message, - 'deploy: These options are mutually exclusive: json, yaml.', + 'deploy: These options are mutually exclusive: --json, --yaml.', ); expect( usage.err.toString(), _errorThenUsage( - 'deploy: These options are mutually exclusive: json, yaml.', + 'deploy: These options are mutually exclusive: --json, --yaml.', deploy.usage, ), ); @@ -597,12 +597,12 @@ void main() { 'along with the usage', () { expect( error?.message, - 'deploy: These options are mutually exclusive: json, yaml.', + 'deploy: These options are mutually exclusive: --json, --yaml.', ); expect( usage.err.toString(), _errorThenUsage( - 'deploy: These options are mutually exclusive: json, yaml.', + 'deploy: These options are mutually exclusive: --json, --yaml.', deploy.usage, ), ); diff --git a/packages/config/test/command/usage_output_test.dart b/packages/config/test/command/usage_output_test.dart index c73ce85..e9fe4b7 100644 --- a/packages/config/test/command/usage_output_test.dart +++ b/packages/config/test/command/usage_output_test.dart @@ -1076,7 +1076,7 @@ String _errorUsageAndCommand( final String commandUsage, ) => '$message\n\n$usage\n---\n$commandUsage'; -const _missingName = 'greet: Option `name` is mandatory.'; +const _missingName = 'greet: Option "--name" is mandatory.'; class _CapturedUsage { final out = StringBuffer(); diff --git a/packages/config/test/config/arg_parser/scan_and_parse_args_test.dart b/packages/config/test/config/arg_parser/scan_and_parse_args_test.dart index 4728112..49ba0f2 100644 --- a/packages/config/test/config/arg_parser/scan_and_parse_args_test.dart +++ b/packages/config/test/config/arg_parser/scan_and_parse_args_test.dart @@ -799,7 +799,7 @@ void main() { isA().having( (final e) => e.toString(), 'toString', - contains('Duplicate argument name: name'), + contains('Duplicate argument name: "name"'), ), ), ); @@ -820,7 +820,7 @@ void main() { isA().having( (final e) => e.toString(), 'toString', - contains('Duplicate argument abbreviation: x'), + contains('Duplicate argument abbreviation: "x"'), ), ), ); @@ -841,7 +841,7 @@ void main() { isA().having( (final e) => e.toString(), 'toString', - contains('Duplicate argument name: no-verbose'), + contains('Duplicate argument name: "no-verbose"'), ), ), ); diff --git a/packages/config/test/config/arg_parser/scan_and_parse_commands_test.dart b/packages/config/test/config/arg_parser/scan_and_parse_commands_test.dart index 2e0cf1c..3dc5534 100644 --- a/packages/config/test/config/arg_parser/scan_and_parse_commands_test.dart +++ b/packages/config/test/config/arg_parser/scan_and_parse_commands_test.dart @@ -1042,7 +1042,7 @@ void main() { isA().having( (final e) => e.toString(), 'toString', - contains('Duplicate argument name: opt'), + contains('Duplicate argument name: "opt"'), ), ), ); @@ -1370,7 +1370,7 @@ void main() { isA().having( (final e) => e.toString(), 'toString', - 'CommandDefinitionError: Invalid definition for command `build`: ' + 'CommandDefinitionError: Invalid definition for command "build": ' 'Duplicate subcommand name: build for command tool', ), ), @@ -1391,7 +1391,7 @@ void main() { isA().having( (final e) => e.toString(), 'toString', - 'CommandDefinitionError: Invalid definition for command `leaf`: ' + 'CommandDefinitionError: Invalid definition for command "leaf": ' 'Duplicate subcommand name: leaf for command mid', ), ), @@ -1427,8 +1427,8 @@ void main() { isA().having( (final e) => e.toString(), 'toString', - 'CommandDefinitionError: Invalid definition for command `tool`: ' - 'Cannot define positional options on a command with subcommands: option `file`.', + 'CommandDefinitionError: Invalid definition for command "tool": ' + 'Cannot define positional options on a command with subcommands: option "--file".', ), ), ); @@ -1453,9 +1453,9 @@ void main() { isA().having( (final e) => e.toString(), 'toString', - 'CommandDefinitionError: Invalid definition for command `tool`: ' + 'CommandDefinitionError: Invalid definition for command "tool": ' 'Persistent options must not be positional: ' - 'positional argument 0.', + 'positional argument {0}.', ), ), ); @@ -1482,9 +1482,9 @@ void main() { isA().having( (final e) => e.toString(), 'toString', - 'CommandDefinitionError: Invalid definition for command `mid`: ' + 'CommandDefinitionError: Invalid definition for command "mid": ' 'Cannot define positional options on a command with subcommands: ' - 'positional argument 0.', + 'positional argument {0}.', ), ), ); @@ -1503,8 +1503,8 @@ void main() { isA().having( (final e) => e.toString(), 'toString', - 'CommandDefinitionError: Invalid definition for command `tool`: ' - 'Persistent options must not be positional: option `file`.', + 'CommandDefinitionError: Invalid definition for command "tool": ' + 'Persistent options must not be positional: option "--file".', ), ), ); @@ -1523,9 +1523,9 @@ void main() { isA().having( (final e) => e.toString(), 'toString', - 'CommandDefinitionError: Invalid definition for command `run`: ' + 'CommandDefinitionError: Invalid definition for command "run": ' 'Persistent options must not be positional: ' - 'positional argument 0.', + 'positional argument {0}.', ), ), ); @@ -2527,8 +2527,8 @@ void main() { isA().having( (final e) => e.toString(), 'toString', - 'CommandDefinitionError: Invalid definition for command `--version`: ' - 'Subcommand name `--version` collides with option `version` ' + 'CommandDefinitionError: Invalid definition for command "--version": ' + 'Subcommand name "--version" collides with flag "--version" ' 'for command tool', ), ), @@ -2555,8 +2555,8 @@ void main() { isA().having( (final e) => e.toString(), 'toString', - 'CommandDefinitionError: Invalid definition for command `--version`: ' - 'Subcommand name `--version` collides with option `version` ' + 'CommandDefinitionError: Invalid definition for command "--version": ' + 'Subcommand name "--version" collides with flag "--version" ' 'for command tool', ), ), @@ -2583,8 +2583,8 @@ void main() { isA().having( (final e) => e.toString(), 'toString', - 'CommandDefinitionError: Invalid definition for command `-V`: ' - 'Subcommand name `-V` collides with option `version` ' + 'CommandDefinitionError: Invalid definition for command "-V": ' + 'Subcommand name "-V" collides with flag "--version" ' 'for command tool', ), ), @@ -2614,8 +2614,8 @@ void main() { isA().having( (final e) => e.toString(), 'toString', - 'CommandDefinitionError: Invalid definition for command `show`: ' - 'Subcommand alias `-V` collides with option `version` ' + 'CommandDefinitionError: Invalid definition for command "show": ' + 'Subcommand alias "-V" collides with flag "--version" ' 'for command tool', ), ), @@ -2640,8 +2640,8 @@ void main() { isA().having( (final e) => e.toString(), 'toString', - 'CommandDefinitionError: Invalid definition for command `--version`: ' - 'Subcommand name `--version` collides with option `name` ' + 'CommandDefinitionError: Invalid definition for command "--version": ' + 'Subcommand name "--version" collides with option "--name" ' 'for command tool', ), ), @@ -2667,8 +2667,8 @@ void main() { isA().having( (final e) => e.toString(), 'toString', - 'CommandDefinitionError: Invalid definition for command `--no-color`: ' - 'Subcommand name `--no-color` collides with option `color` ' + 'CommandDefinitionError: Invalid definition for command "--no-color": ' + 'Subcommand name "--no-color" collides with flag "--color" ' 'for command tool', ), ), @@ -2696,8 +2696,8 @@ void main() { isA().having( (final e) => e.toString(), 'toString', - 'CommandDefinitionError: Invalid definition for command `--verbose`: ' - 'Subcommand name `--verbose` collides with option `verbose` ' + 'CommandDefinitionError: Invalid definition for command "--verbose": ' + 'Subcommand name "--verbose" collides with flag "--verbose" ' 'for command mid', ), ), diff --git a/packages/config/test/config/configuration_test.dart b/packages/config/test/config/configuration_test.dart index 65d495d..6cb6670 100644 --- a/packages/config/test/config/configuration_test.dart +++ b/packages/config/test/config/configuration_test.dart @@ -985,7 +985,7 @@ void main() async { env: envVars, ); expect(config.errors, hasLength(1)); - expect(config.errors.first, 'option `project` is mandatory'); + expect(config.errors.first, 'option "--project" is mandatory'); expect( () => config.value(projectIdOpt), throwsA( @@ -993,7 +993,7 @@ void main() async { (final e) => e.message, 'message', contains( - 'No value available for option `project` due to previous errors', + 'No value available for option "--project" due to previous errors', ), ), ), @@ -1015,7 +1015,7 @@ void main() async { .having( (final e) => e.message, 'message', - contains('Option `project` is mandatory.'), + contains('Option "--project" is mandatory.'), ) .having( (final e) => e.usage, @@ -1067,7 +1067,7 @@ void main() async { env: envVars, ); expect(config.errors, hasLength(1)); - expect(config.errors.first, 'option `project` is mandatory'); + expect(config.errors.first, 'option "--project" is mandatory'); expect( () => config.value(projectIdOpt), throwsA( @@ -1075,7 +1075,7 @@ void main() async { (final e) => e.message, 'message', contains( - 'No value available for option `project` due to previous errors', + 'No value available for option "--project" due to previous errors', ), ), ), @@ -1200,7 +1200,7 @@ void main() async { allOf( isA(), (final e) => e.toString().contains( - 'Duplicate argument name: no-color', + 'Duplicate argument name: alias "no-color"', ), ), ), @@ -1249,7 +1249,7 @@ void main() async { allOf( isA(), (final e) => e.toString().contains( - 'Duplicate argument abbreviation: x', + 'Duplicate argument abbreviation: "x"', ), ), ), @@ -1435,7 +1435,7 @@ void main() async { env: envVars, ); expect(config.errors, hasLength(1)); - expect(config.errors.first, 'positional argument 0 is mandatory'); + expect(config.errors.first, 'positional argument {0} is mandatory'); expect( () => config.value(positionalOpt), throwsA( @@ -1443,7 +1443,7 @@ void main() async { (final e) => e.message, 'message', contains( - 'No value available for positional argument 0 due to previous errors', + 'No value available for positional argument {0} due to previous errors', ), ), ), @@ -2145,7 +2145,7 @@ void main() async { expect(config.errors, hasLength(1)); expect( config.errors.single, - 'These options are mutually exclusive: first, second', + 'These options are mutually exclusive: --first, --second', ); }, ); @@ -2161,7 +2161,7 @@ void main() async { expect(config.errors, hasLength(1)); expect( config.errors.single, - 'These options are mutually exclusive: first, second', + 'These options are mutually exclusive: --first, --second', ); }, ); @@ -2261,7 +2261,7 @@ void main() async { expect(config.errors, hasLength(1)); expect( config.errors.single, - 'These options are mutually exclusive: first, second', + 'These options are mutually exclusive: --first, --second', ); }, ); @@ -2277,7 +2277,7 @@ void main() async { expect(config.errors, hasLength(1)); expect( config.errors.single, - 'These options are mutually exclusive: first, second', + 'These options are mutually exclusive: --first, --second', ); }, ); @@ -2389,7 +2389,7 @@ void main() async { expect(config.errors, hasLength(1)); expect( config.errors.single, - 'These options are mutually exclusive: first, second', + 'These options are mutually exclusive: --first, --second', ); }, ); @@ -2454,7 +2454,7 @@ void main() async { expect(config.errors, hasLength(1)); expect( config.errors.single, - 'These options are mutually exclusive: first, second', + 'These options are mutually exclusive: --first, --second', ); }, ); @@ -2509,7 +2509,7 @@ void main() async { isA().having( (final e) => e.message, 'message', - 'Out-of-order dependency on not-yet-resolved option `file`', + 'Out-of-order dependency on not-yet-resolved option "--file"', ), ), ); @@ -2579,7 +2579,7 @@ void main() async { isA().having( (final e) => e.message, 'message', - 'option `otherInt` is not part of this configuration', + 'option "--otherInt" is not part of this configuration', ), ), ); diff --git a/packages/config/test/config/configuration_type_test.dart b/packages/config/test/config/configuration_type_test.dart index 079f9d4..10fbaca 100644 --- a/packages/config/test/config/configuration_type_test.dart +++ b/packages/config/test/config/configuration_type_test.dart @@ -48,7 +48,7 @@ void main() async { expect(config.errors, hasLength(1)); expect( config.errors.single, - equals('Invalid value for option `name`: Value must not be empty'), + equals('Invalid value for option "--name": Value must not be empty'), ); }); @@ -61,7 +61,7 @@ void main() async { expect(config.errors, hasLength(1)); expect( config.errors.single, - equals('Invalid value for option `name`: Value must not be empty'), + equals('Invalid value for option "--name": Value must not be empty'), ); }); @@ -76,7 +76,7 @@ void main() async { expect(config.errors, hasLength(1)); expect( config.errors.single, - equals('Invalid value for option `name`: Value must not be empty'), + equals('Invalid value for option "--name": Value must not be empty'), ); }, ); @@ -115,7 +115,7 @@ void main() async { expect(config.errors, hasLength(1)); expect( config.errors.single, - equals('Invalid value for option `name`: Value must not be empty'), + equals('Invalid value for option "--name": Value must not be empty'), ); }); @@ -160,7 +160,7 @@ void main() async { expect( config.errors.single, equals( - 'Invalid value for option `animal`: "unicorn" is not in cat|dog|mouse', + 'Invalid value for option "--animal": "unicorn" is not in cat|dog|mouse', ), ); }); @@ -206,7 +206,7 @@ void main() async { expect(config.errors, hasLength(1)); expect( config.errors.single, - contains('Invalid value for option `number` '), + contains('Invalid value for option "--number" '), ); }); test('when passed a non-number value then it reports an error', () async { @@ -219,7 +219,7 @@ void main() async { expect(config.errors, hasLength(1)); expect( config.errors.single, - contains('Invalid value for option `number` '), + contains('Invalid value for option "--number" '), ); }); }); @@ -254,7 +254,7 @@ void main() async { expect( config.errors.single, equals( - 'Invalid value for option `number` : 99 is below the minimum (100)', + 'Invalid value for option "--number" : 99 is below the minimum (100)', ), ); }, @@ -272,7 +272,7 @@ void main() async { expect( config.errors.single, equals( - 'Invalid value for option `number` : 201 is above the maximum (200)', + 'Invalid value for option "--number" : 201 is above the maximum (200)', ), ); }, @@ -306,7 +306,7 @@ void main() async { expect(config.errors, hasLength(1)); expect( config.errors.single, - contains('`99` is not an allowed value for option `number`'), + contains('`99` is not an allowed value for option "--number"'), ); }, ); @@ -323,8 +323,8 @@ void main() async { expect( config.errors.single, equals( - 'Invalid value for option `number` : ' - '`99` is not an allowed value for option `number`', + 'Invalid value for option "--number" : ' + '`99` is not an allowed value for option "--number"', ), ); }, @@ -385,7 +385,7 @@ void main() async { expect(config.errors, hasLength(1)); expect( config.errors.single, - contains('Invalid value for option `number` '), + contains('Invalid value for option "--number" '), ); }); }); @@ -420,7 +420,7 @@ void main() async { expect( config.errors.single, equals( - 'Invalid value for option `number` : ' + 'Invalid value for option "--number" : ' '0.4 is below the minimum (0.5)', ), ); @@ -440,7 +440,7 @@ void main() async { expect( config.errors.single, equals( - 'Invalid value for option `number` : ' + 'Invalid value for option "--number" : ' '1.6 is above the maximum (1.5)', ), ); @@ -491,7 +491,7 @@ void main() async { ); expect(config.errors, [ - 'option `number` value true is of type bool, not double.', + 'option "--number" value true is of type bool, not double.', ]); }); }); @@ -529,7 +529,7 @@ void main() async { ); expect(config.errors, [ - 'Invalid value for option `number` : ' + 'Invalid value for option "--number" : ' '-0.1 is below the minimum (0.0)', ]); }); @@ -541,7 +541,7 @@ void main() async { ); expect(config.errors, [ - 'Invalid value for option `number` : ' + 'Invalid value for option "--number" : ' 'NaN is not a valid number', ]); }); @@ -558,7 +558,7 @@ void main() async { ); expect(config.errors, [ - 'Invalid value for option `number` : ' + 'Invalid value for option "--number" : ' 'NaN is not a valid number', ]); }); @@ -680,7 +680,7 @@ void main() async { expect( config.errors.single, equals( - 'Invalid value for option `duration` : -2s is below the minimum (0s)', + 'Invalid value for option "--duration" : -2s is below the minimum (0s)', ), ); }, @@ -699,7 +699,7 @@ void main() async { expect( config.errors.single, equals( - 'Invalid value for option `duration` : 20d is above the maximum (2d)', + 'Invalid value for option "--duration" : 20d is above the maximum (2d)', ), ); }, @@ -807,7 +807,7 @@ void main() async { expect( config.errors.single, equals( - 'option `many` value [] is of type List, not List.', + 'option "--many" value [] is of type List, not List.', ), ); }, @@ -850,7 +850,7 @@ void main() async { expect( config.errors.single, equals( - 'option `many` value [123] is of type List, not List.', + 'option "--many" value [123] is of type List, not List.', ), ); }, @@ -926,7 +926,7 @@ void main() async { expect( config.errors.single, startsWith( - 'Invalid value for option `many`: Invalid number (at character 1)', + 'Invalid value for option "--many": Invalid number (at character 1)', ), ); }); @@ -964,7 +964,7 @@ void main() async { expect( config.errors.single, equals( - 'option `many` value [] is of type List, not List.', + 'option "--many" value [] is of type List, not List.', ), ); }, @@ -1005,7 +1005,7 @@ void main() async { expect( config.errors.single, startsWith( - 'Invalid value for option `many`: Invalid radix-10 number (at character 1)', + 'Invalid value for option "--many": Invalid radix-10 number (at character 1)', ), ); }, @@ -1024,7 +1024,7 @@ void main() async { expect( config.errors.single, equals( - 'option `many` value [123] is of type List, not List.', + 'option "--many" value [123] is of type List, not List.', ), ); }, @@ -1101,7 +1101,7 @@ void main() async { expect( config.errors.single, startsWith( - 'Invalid value for option `many`: Invalid number (at character 1)', + 'Invalid value for option "--many": Invalid number (at character 1)', ), ); }); @@ -1148,7 +1148,7 @@ void main() async { expect(config.errors, hasLength(1)); expect( config.errors.single, - equals('option `many` is mandatory'), + equals('option "--many" is mandatory'), ); }); @@ -1203,7 +1203,7 @@ void main() async { expect( config.errors.single, startsWith( - 'Invalid value for option `many`: Invalid number (at character 1)', + 'Invalid value for option "--many": Invalid number (at character 1)', ), ); }); @@ -1266,7 +1266,7 @@ void main() async { expect(config.errors, hasLength(1)); expect( config.errors.single, - contains('`wrong` is not an allowed value for option `many`'), + contains('`wrong` is not an allowed value for option "--many"'), ); expect( () => config.optionalValue(typedOpt), @@ -1287,7 +1287,7 @@ void main() async { expect( config.errors.single, equals( - 'Invalid value for option `many`: `wrong` is not an allowed value for option `many`', + 'Invalid value for option "--many": `wrong` is not an allowed value for option "--many"', ), ); expect( @@ -1308,7 +1308,7 @@ void main() async { expect(config.errors, hasLength(1)); expect( config.errors.single, - contains('`wrong` is not an allowed value for option `many`'), + contains('`wrong` is not an allowed value for option "--many"'), ); expect( () => config.optionalValue(typedOpt), diff --git a/packages/config/test/config/date_parsing_test.dart b/packages/config/test/config/date_parsing_test.dart index 30e6e04..d6b445f 100644 --- a/packages/config/test/config/date_parsing_test.dart +++ b/packages/config/test/config/date_parsing_test.dart @@ -316,7 +316,7 @@ void main() { args: ['--before', '2026-02-31'], ); expect(config.errors, [ - 'Invalid value for option `before` : ' + 'Invalid value for option "--before" : ' 'Invalid date-time "2026-02-31": day must be between 1 and 28', ]); }); @@ -329,7 +329,7 @@ void main() { args: ['--on', '2026-08-01T00:00:00Z'], ); expect(config.errors, [ - 'Invalid value for option `on` : ' + 'Invalid value for option "--on" : ' 'Invalid date "2026-08-01T00:00:00Z": a time is not allowed', ]); }, @@ -357,7 +357,7 @@ void main() { args: ['--before', '2026-08-02'], ); expect(config.errors, [ - 'Invalid value for option `before` : ' + 'Invalid value for option "--before" : ' '2026-08-02T00:00:00 is above the maximum ' '(2026-08-01T00:00:00Z)', ]); @@ -455,7 +455,7 @@ void main() { return; } expect(config.errors, [ - 'Invalid value for option `on` : ' + 'Invalid value for option "--on" : ' '2011-12-30 does not exist in the local time zone', ]); }, @@ -498,8 +498,8 @@ void main() { args: ['--on', '2026-10-01'], ); expect(config.errors, [ - 'Invalid value for option `on` : ' - '`2026-10-01 00:00:00.000` is not an allowed value for option `on`', + 'Invalid value for option "--on" : ' + '`2026-10-01 00:00:00.000` is not an allowed value for option "--on"', ]); }); }); diff --git a/packages/config/test/config/file_options_test.dart b/packages/config/test/config/file_options_test.dart index ac13dc5..6886591 100644 --- a/packages/config/test/config/file_options_test.dart +++ b/packages/config/test/config/file_options_test.dart @@ -71,7 +71,7 @@ void main() async { expect( config.errors.single, equals( - 'Invalid value for option `folder`: Path "$filePath" is not a directory', + 'Invalid value for option "--folder": Path "$filePath" is not a directory', ), ); }); @@ -96,7 +96,7 @@ void main() async { expect( config.errors.single, equals( - 'Invalid value for option `folder`: Directory "does-not-exist" does not exist', + 'Invalid value for option "--folder": Directory "does-not-exist" does not exist', ), ); }); @@ -146,7 +146,7 @@ void main() async { expect( config.errors.single, equals( - 'Invalid value for option `folder`: Path "$filePath" is not a directory', + 'Invalid value for option "--folder": Path "$filePath" is not a directory', ), ); }); @@ -195,7 +195,7 @@ void main() async { expect( config.errors.single, equals( - 'Invalid value for option `folder`: Path "$dirPath" already exists', + 'Invalid value for option "--folder": Path "$dirPath" already exists', ), ); }); @@ -221,7 +221,7 @@ void main() async { expect( config.errors.single, equals( - 'Invalid value for option `folder`: Path "$filePath" already exists', + 'Invalid value for option "--folder": Path "$filePath" already exists', ), ); }); @@ -272,7 +272,7 @@ void main() async { expect( config.errors.single, equals( - 'Invalid value for option `file`: Path "$dirPath" is not a file', + 'Invalid value for option "--file": Path "$dirPath" is not a file', ), ); }); @@ -321,7 +321,7 @@ void main() async { expect( config.errors.single, equals( - 'Invalid value for option `file`: File "does-not-exist" does not exist', + 'Invalid value for option "--file": File "does-not-exist" does not exist', ), ); }); @@ -347,7 +347,7 @@ void main() async { expect( config.errors.single, equals( - 'Invalid value for option `file`: Path "$dirPath" is not a file', + 'Invalid value for option "--file": Path "$dirPath" is not a file', ), ); }); @@ -420,7 +420,7 @@ void main() async { expect( config.errors.single, equals( - 'Invalid value for option `file`: Path "$dirPath" already exists', + 'Invalid value for option "--file": Path "$dirPath" already exists', ), ); }); @@ -446,7 +446,7 @@ void main() async { expect( config.errors.single, equals( - 'Invalid value for option `file`: Path "$filePath" already exists', + 'Invalid value for option "--file": Path "$filePath" already exists', ), ); });