From 2188951b1d1651dd1f700b0e0ad6a7d886025732 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 7 Sep 2026 14:43:53 +0000 Subject: [PATCH 1/2] chore(deps): bump very_good_analysis from 10.3.0 to 11.0.0 Bumps [very_good_analysis](https://github.com/VeryGoodOpenSource/very_good_analysis) from 10.3.0 to 11.0.0. - [Release notes](https://github.com/VeryGoodOpenSource/very_good_analysis/releases) - [Changelog](https://github.com/VeryGoodOpenSource/very_good_analysis/blob/main/CHANGELOG.md) - [Commits](https://github.com/VeryGoodOpenSource/very_good_analysis/compare/v10.3.0...v11.0.0) --- updated-dependencies: - dependency-name: very_good_analysis dependency-version: 11.0.0 dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pubspec.yaml b/pubspec.yaml index f5090f8..0b76929 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -21,4 +21,4 @@ dependencies: dev_dependencies: mocktail: ^1.0.4 test: ^1.25.8 - very_good_analysis: ^10.3.0 + very_good_analysis: ">=10.3.0 <12.0.0" From e25caa30c22604c35f5cd80b97bc274e82fc16f5 Mon Sep 17 00:00:00 2001 From: "unicoderbot[bot]" <269805761+unicoderbot[bot]@users.noreply.github.com> Date: Thu, 15 Oct 2026 20:28:24 +0000 Subject: [PATCH 2/2] fix: address review feedback on PR #137 Co-authored-by: erickzanardo --- example/bin/example_cli.dart | 6 +- example/lib/src/command_runner.dart | 13 +- example/lib/src/commands/some_commmand.dart | 36 +- .../lib/src/commands/some_other_commmand.dart | 4 +- example/pubspec.yaml | 2 +- .../completion_integration_test.dart | 97 +- example/test/integration/utils.dart | 46 +- example/test/src/command_runner_test.dart | 26 +- .../test/src/commands/some_command_test.dart | 6 +- .../src/commands/some_other_command_test.dart | 11 +- .../commands/handle_completion_command.dart | 2 +- .../install_completion_files_command.dart | 2 +- .../print_completion_script_command.dart | 2 +- .../uninstall_completion_files_command.dart | 2 +- .../completion_command_runner.dart | 4 +- .../installer/completion_configuration.dart | 11 +- .../installer/completion_installation.dart | 4 +- lib/src/installer/exceptions.dart | 10 +- .../installer/script_configuration_entry.dart | 13 +- .../shell_completion_configuration.dart | 6 +- lib/src/parser/completion_level.dart | 2 +- lib/src/parser/completion_result.dart | 24 +- lib/src/parser/completion_state.dart | 2 +- lib/src/parser/parser.dart | 4 +- lib/src/system_shell.dart | 6 +- pubspec.yaml | 2 +- .../handle_completion_command_test.dart | 14 +- ...install_completion_files_command_test.dart | 16 +- .../print_completion_script_command_test.dart | 35 +- ...install_completion_files_command_test.dart | 16 +- .../completion_command_runner_test.dart | 132 +-- .../completion_configuration_test.dart | 18 +- .../completion_installation_test.dart | 923 ++++++++---------- .../script_configuration_entry_test.dart | 89 +- .../src/parser/arg_parser_extension_test.dart | 13 +- test/src/parser/completion_level_test.dart | 148 ++- test/src/parser/completion_result_test.dart | 234 ++--- test/src/parser/completion_state_test.dart | 36 +- test/src/parser/parser_test.dart | 29 +- test/src/system_shell_test.dart | 47 +- 40 files changed, 813 insertions(+), 1280 deletions(-) diff --git a/example/bin/example_cli.dart b/example/bin/example_cli.dart index 1600f65..8250a50 100644 --- a/example/bin/example_cli.dart +++ b/example/bin/example_cli.dart @@ -13,8 +13,6 @@ Future main(List args) async { /// exited already. This is useful to prevent Future chains from proceeding /// after you've decided to exit. Future _flushThenExit(int status) { - return Future.wait([ - stdout.close(), - stderr.close(), - ]).then((_) => exit(status)); + return Future.wait([stdout.close(), stderr.close()]) + .then((_) => exit(status)); } diff --git a/example/lib/src/command_runner.dart b/example/lib/src/command_runner.dart index 9613f70..495a740 100644 --- a/example/lib/src/command_runner.dart +++ b/example/lib/src/command_runner.dart @@ -16,17 +16,12 @@ const description = 'Example for cli_completion'; /// {@endtemplate} class ExampleCommandRunner extends CompletionCommandRunner { /// {@macro example_command_runner} - ExampleCommandRunner({ - Logger? logger, - }) : _logger = logger ?? Logger(), - super(executableName, description) { + new({Logger? logger}) + : _logger = logger ?? Logger(), + super(executableName, description) { // Add root options and flags argParser - ..addFlag( - 'rootFlag', - abbr: 'f', - help: 'A flag: in the root command', - ) + ..addFlag('rootFlag', abbr: 'f', help: 'A flag: in the root command') ..addOption('rootOption'); // Add sub commands diff --git a/example/lib/src/commands/some_commmand.dart b/example/lib/src/commands/some_commmand.dart index adb2134..7c735a6 100644 --- a/example/lib/src/commands/some_commmand.dart +++ b/example/lib/src/commands/some_commmand.dart @@ -5,30 +5,19 @@ import 'package:mason_logger/mason_logger.dart'; /// receives all the common cases of option mapping: options, muilt-options, /// flags and whatnot class SomeCommand extends Command { - SomeCommand(this._logger) { + new(this._logger) { argParser ..addOption( 'discrete', abbr: 'd', help: 'A discrete option with "allowed" values (mandatory)', allowed: ['foo', 'bar', 'faa'], - aliases: [ - 'allowed', - 'defined-values', - ], - allowedHelp: { - 'foo': 'foo help', - 'bar': 'bar help', - 'faa': 'faa help', - }, + aliases: ['allowed', 'defined-values'], + allowedHelp: {'foo': 'foo help', 'bar': 'bar help', 'faa': 'faa help'}, mandatory: true, ) ..addSeparator('yay') - ..addOption( - 'hidden', - hide: true, - help: 'A hidden option', - ) + ..addOption('hidden', hide: true, help: 'A hidden option') ..addOption( 'continuous', // intentionally, this one does not have an abbr help: 'A continuous option: any value is allowed', @@ -62,16 +51,8 @@ class SomeCommand extends Command { abbr: 'n', help: 'An continuous option that can be passed multiple times', ) - ..addFlag( - 'hiddenflag', - hide: true, - help: 'A hidden flag', - ) - ..addFlag( - 'flag', - abbr: 'f', - aliases: ['itIsAFlag'], - ) + ..addFlag('hiddenflag', hide: true, help: 'A hidden flag') + ..addFlag('flag', abbr: 'f', aliases: ['itIsAFlag']) ..addFlag( 'inverseflag', abbr: 'i', @@ -95,10 +76,7 @@ class SomeCommand extends Command { String get name => 'some_command'; @override - List get aliases => [ - 'disguised:some_commmand', - 'melon', - ]; + List get aliases => ['disguised:some_commmand', 'melon']; @override Future run() async { diff --git a/example/lib/src/commands/some_other_commmand.dart b/example/lib/src/commands/some_other_commmand.dart index d95f026..3261d34 100644 --- a/example/lib/src/commands/some_other_commmand.dart +++ b/example/lib/src/commands/some_other_commmand.dart @@ -3,7 +3,7 @@ import 'package:mason_logger/mason_logger.dart'; /// A command that only has a sub command class SomeOtherCommand extends Command { - SomeOtherCommand(this._logger) { + new(this._logger) { addSubcommand(_SomeSubCommand(_logger)); } @@ -19,7 +19,7 @@ class SomeOtherCommand extends Command { /// A command under [SomeOtherCommand] that does not receive options and read /// the "rest" field from arg results class _SomeSubCommand extends Command { - _SomeSubCommand(this._logger) { + new(this._logger) { argParser.addFlag( 'flag', help: 'a flag just to show we are in the subcommand', diff --git a/example/pubspec.yaml b/example/pubspec.yaml index d6d51b9..d0c2f45 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -15,7 +15,7 @@ dependencies: dev_dependencies: mocktail: ^1.0.4 test: ^1.25.8 - very_good_analysis: ^10.3.0 + very_good_analysis: ^11.0.0 executables: example_cli: diff --git a/example/test/integration/completion_integration_test.dart b/example/test/integration/completion_integration_test.dart index dda1bc7..f72d06d 100644 --- a/example/test/integration/completion_integration_test.dart +++ b/example/test/integration/completion_integration_test.dart @@ -108,17 +108,11 @@ void main() { }); test('totally written option', () async { - await expectLater( - 'example_cli --rootflag', - suggests(noSuggestions), - ); + await expectLater('example_cli --rootflag', suggests(noSuggestions)); }); test('totally written option (abbr)', () async { - await expectLater( - 'example_cli -f', - suggests(noSuggestions), - ); + await expectLater('example_cli -f', suggests(noSuggestions)); }); }); @@ -147,9 +141,7 @@ void main() { test('completes only one sub command', () async { await expectLater( 'example_cli some_comm', - suggests({ - 'some_command': 'This is help for some_command', - }), + suggests({'some_command': 'This is help for some_command'}), ); }); }); @@ -158,9 +150,7 @@ void main() { test('completes sub commands aliases when typed', () async { await expectLater( 'example_cli mel', - suggests({ - 'melon': 'This is help for some_command', - }), + suggests({'melon': 'This is help for some_command'}), ); }); @@ -245,16 +235,12 @@ void main() { ); }); - test( - 'options in between', - () async { - await expectLater( - 'example_cli -f --rootOption yay some_command', - suggests(allOptionsInThisLevel), - ); - }, - tags: 'known-issues', - ); + test('options in between', () async { + await expectLater( + 'example_cli -f --rootOption yay some_command', + suggests(allOptionsInThisLevel), + ); + }, tags: 'known-issues'); test('lots of spaces in between', () async { await expectLater( @@ -266,10 +252,7 @@ void main() { group('empty (aliases)', () { test('shows same options for alias sub command', () async { - await expectLater( - 'example_cli melon', - suggests(allOptionsInThisLevel), - ); + await expectLater('example_cli melon', suggests(allOptionsInThisLevel)); }); test('shows same options for alias sub command 2', () async { @@ -391,21 +374,14 @@ void main() { test('suggest possible options', () async { await expectLater( 'example_cli some_command --discrete ', - suggests({ - 'foo': 'foo help', - 'bar': 'bar help', - 'faa': 'faa help', - }), + suggests({'foo': 'foo help', 'bar': 'bar help', 'faa': 'faa help'}), ); }); test('suggest matching options', () async { await expectLater( 'example_cli some_command --discrete f', - suggests({ - 'foo': 'foo help', - 'faa': 'faa help', - }), + suggests({'foo': 'foo help', 'faa': 'faa help'}), ); }); @@ -424,11 +400,7 @@ void main() { test('suggest matching options for alias option when typed', () async { await expectLater( 'example_cli some_command --allowed ', - suggests({ - 'foo': 'foo help', - 'bar': 'bar help', - 'faa': 'faa help', - }), + suggests({'foo': 'foo help', 'bar': 'bar help', 'faa': 'faa help'}), ); }); @@ -462,11 +434,7 @@ void main() { test('suggest possible options', () async { await expectLater( 'example_cli some_command -d ', - suggests({ - 'foo': 'foo help', - 'bar': 'bar help', - 'faa': 'faa help', - }), + suggests({'foo': 'foo help', 'bar': 'bar help', 'faa': 'faa help'}), ); }); @@ -484,20 +452,14 @@ void main() { test('suggest matching options', () async { await expectLater( 'example_cli some_command -d f', - suggests({ - 'foo': 'foo help', - 'faa': 'faa help', - }), + suggests({'foo': 'foo help', 'faa': 'faa help'}), ); }); test('suggest matching options in a joined form', () async { await expectLater( 'example_cli some_command -df', - suggests({ - '-dfoo': 'foo help', - '-dfaa': 'faa help', - }), + suggests({'-dfoo': 'foo help', '-dfaa': 'faa help'}), ); }); }); @@ -626,16 +588,12 @@ void main() { ); }); - test( - 'include option after it is specified (abbr joined)', - () async { - await expectLater( - 'example_cli some_command -nyeahoo ', - suggests(allOptionsInThisLevel), - ); - }, - tags: 'known-issues', - ); + test('include option after it is specified (abbr joined)', () async { + await expectLater( + 'example_cli some_command -nyeahoo ', + suggests(allOptionsInThisLevel), + ); + }, tags: 'known-issues'); test( 'include discrete multi option value after it is specified', @@ -672,9 +630,7 @@ void main() { test('partially written sub command', () async { await expectLater( 'example_cli some_other_command sub', - suggests({ - 'subcommand': 'A sub command of some_other_command', - }), + suggests({'subcommand': 'A sub command of some_other_command'}), ); }); }); @@ -721,10 +677,7 @@ void main() { group('argument terminator bails', () { test('between commands', () async { - await expectLater( - 'example_cli -- some_command', - suggests(noSuggestions), - ); + await expectLater('example_cli -- some_command', suggests(noSuggestions)); }); test('after commands', () async { diff --git a/example/test/integration/utils.dart b/example/test/integration/utils.dart index c2a3c28..b45f80a 100644 --- a/example/test/integration/utils.dart +++ b/example/test/integration/utils.dart @@ -5,23 +5,18 @@ import 'package:mocktail/mocktail.dart'; import 'package:test/test.dart'; -class MockStdout extends Mock implements Stdout {} +class MockStdout extends Mock implements Stdout; Matcher suggests(Map suggestions, {int? whenCursorIsAt}) => - CliCompletionMatcher( - suggestions, - cursorIndex: whenCursorIsAt, - ); + CliCompletionMatcher(suggestions, cursorIndex: whenCursorIsAt); class CliCompletionMatcher extends CustomMatcher { - CliCompletionMatcher( - Map suggestions, { - this.cursorIndex, - }) : super( - 'Completes with the expected suggestions', - 'suggestions', - completion(suggestions), - ); + new(Map suggestions, {this.cursorIndex}) + : super( + 'Completes with the expected suggestions', + 'suggestions', + completion(suggestions), + ); final int? cursorIndex; @@ -47,11 +42,7 @@ Map prepareEnvForLineInput(String line, {int? cursorIndex}) { } return value; }); - return { - 'COMP_LINE': line, - 'COMP_POINT': '$cpoint', - 'COMP_CWORD': '$cword', - }; + return {'COMP_LINE': line, 'COMP_POINT': '$cpoint', 'COMP_CWORD': '$cword'}; } Future> runCompletionCommand( @@ -74,17 +65,14 @@ Future> runCompletionCommand( map[res.first] = description; }); - await IOOverrides.runZoned( - stdout: () => stdout, - () async { - final commandRunner = ExampleCommandRunner() - ..environmentOverride = { - 'SHELL': '/foo/bar/zsh', - ...prepareEnvForLineInput(line, cursorIndex: cursorIndex), - }; - await commandRunner.run(['completion']); - }, - ); + await IOOverrides.runZoned(stdout: () => stdout, () async { + final commandRunner = ExampleCommandRunner() + ..environmentOverride = { + 'SHELL': '/foo/bar/zsh', + ...prepareEnvForLineInput(line, cursorIndex: cursorIndex), + }; + await commandRunner.run(['completion']); + }); return map; } diff --git a/example/test/src/command_runner_test.dart b/example/test/src/command_runner_test.dart index b10976b..cc4a1f3 100644 --- a/example/test/src/command_runner_test.dart +++ b/example/test/src/command_runner_test.dart @@ -4,7 +4,7 @@ import 'package:mason_logger/mason_logger.dart'; import 'package:mocktail/mocktail.dart'; import 'package:test/test.dart'; -class MockLogger extends Mock implements Logger {} +class MockLogger extends Mock implements Logger; void main() { group('ExampleCommandRunner', () { @@ -14,18 +14,13 @@ void main() { setUp(() { logger = MockLogger(); - commandRunner = ExampleCommandRunner( - logger: logger, - ); + commandRunner = ExampleCommandRunner(logger: logger); }); - test( - 'can be instantiated without an explicit logger instance', - () { - final commandRunner = ExampleCommandRunner(); - expect(commandRunner, isNotNull); - }, - ); + test('can be instantiated without an explicit logger instance', () { + final commandRunner = ExampleCommandRunner(); + expect(commandRunner, isNotNull); + }); test('handles FormatException', () async { const exception = FormatException('oops!'); @@ -61,9 +56,8 @@ void main() { test('does nothing', () async { final result = await commandRunner.run(['--rootFlag']); expect(result, equals(ExitCode.success.code)); - verify( - () => logger.info('You used the root flag, it does nothing :)'), - ).called(1); + verify(() => logger.info('You used the root flag, it does nothing :)')) + .called(1); }); }); @@ -71,9 +65,7 @@ void main() { test('usesLogger', () async { commandRunner.printUsage(); - final a = verify( - () => logger.info(captureAny()), - ).captured; + final a = verify(() => logger.info(captureAny())).captured; expect(a.first, ''' Example for cli_completion diff --git a/example/test/src/commands/some_command_test.dart b/example/test/src/commands/some_command_test.dart index 2233ab0..1843d17 100644 --- a/example/test/src/commands/some_command_test.dart +++ b/example/test/src/commands/some_command_test.dart @@ -3,7 +3,7 @@ import 'package:mason_logger/mason_logger.dart'; import 'package:mocktail/mocktail.dart'; import 'package:test/test.dart'; -class MockLogger extends Mock implements Logger {} +class MockLogger extends Mock implements Logger; void main() { group('SomeCommand', () { @@ -13,9 +13,7 @@ void main() { setUp(() { logger = MockLogger(); - commandRunner = ExampleCommandRunner( - logger: logger, - ); + commandRunner = ExampleCommandRunner(logger: logger); }); test('list passed options', () async { diff --git a/example/test/src/commands/some_other_command_test.dart b/example/test/src/commands/some_other_command_test.dart index e8c296f..c77013b 100644 --- a/example/test/src/commands/some_other_command_test.dart +++ b/example/test/src/commands/some_other_command_test.dart @@ -3,7 +3,7 @@ import 'package:mason_logger/mason_logger.dart'; import 'package:mocktail/mocktail.dart'; import 'package:test/test.dart'; -class MockLogger extends Mock implements Logger {} +class MockLogger extends Mock implements Logger; void main() { group('SomeOtherCommand', () { @@ -13,9 +13,7 @@ void main() { setUp(() { logger = MockLogger(); - commandRunner = ExampleCommandRunner( - logger: logger, - ); + commandRunner = ExampleCommandRunner(logger: logger); }); test('list passed options', () async { @@ -25,9 +23,8 @@ void main() { expect(exitCode, ExitCode.success.code); - verify( - () => logger.info('A sub command of some_other_command'), - ).called(1); + verify(() => logger.info('A sub command of some_other_command')) + .called(1); verify(() => logger.info(' - anything')).called(1); verify(() => logger.info(' - after')).called(1); verify(() => logger.info(' - command')).called(1); diff --git a/lib/src/command_runner/commands/handle_completion_command.dart b/lib/src/command_runner/commands/handle_completion_command.dart index b124c12..4ca8a96 100644 --- a/lib/src/command_runner/commands/handle_completion_command.dart +++ b/lib/src/command_runner/commands/handle_completion_command.dart @@ -14,7 +14,7 @@ import 'package:cli_completion/parser.dart'; /// for completions. class HandleCompletionRequestCommand extends Command { /// {@macro handle_completion_request_command} - HandleCompletionRequestCommand(); + new(); @override String get description { diff --git a/lib/src/command_runner/commands/install_completion_files_command.dart b/lib/src/command_runner/commands/install_completion_files_command.dart index 76c0e53..2b0ae30 100644 --- a/lib/src/command_runner/commands/install_completion_files_command.dart +++ b/lib/src/command_runner/commands/install_completion_files_command.dart @@ -17,7 +17,7 @@ import 'package:mason_logger/mason_logger.dart'; /// this command logs messages during the installation process. class InstallCompletionFilesCommand extends Command { /// {@macro install_completion_command} - InstallCompletionFilesCommand() { + new() { argParser.addFlag( 'verbose', abbr: 'v', diff --git a/lib/src/command_runner/commands/print_completion_script_command.dart b/lib/src/command_runner/commands/print_completion_script_command.dart index 68adf71..91a2526 100644 --- a/lib/src/command_runner/commands/print_completion_script_command.dart +++ b/lib/src/command_runner/commands/print_completion_script_command.dart @@ -22,7 +22,7 @@ import 'package:cli_completion/cli_completion.dart'; /// {@endtemplate} class PrintCompletionScriptCommand extends Command { /// {@macro print_completion_script_command} - PrintCompletionScriptCommand(); + new(); @override String get description { diff --git a/lib/src/command_runner/commands/uninstall_completion_files_command.dart b/lib/src/command_runner/commands/uninstall_completion_files_command.dart index 0ecc312..fd79f1c 100644 --- a/lib/src/command_runner/commands/uninstall_completion_files_command.dart +++ b/lib/src/command_runner/commands/uninstall_completion_files_command.dart @@ -14,7 +14,7 @@ import 'package:mason_logger/mason_logger.dart'; /// {@endtemplate} class UnistallCompletionFilesCommand extends Command { /// {@macro uninstall_completion_command} - UnistallCompletionFilesCommand() { + new() { argParser.addFlag( 'verbose', abbr: 'v', diff --git a/lib/src/command_runner/completion_command_runner.dart b/lib/src/command_runner/completion_command_runner.dart index 4128001..c4d1e95 100644 --- a/lib/src/command_runner/completion_command_runner.dart +++ b/lib/src/command_runner/completion_command_runner.dart @@ -26,7 +26,7 @@ import 'package:meta/meta.dart'; /// and install it manually. abstract class CompletionCommandRunner extends CommandRunner { /// {@macro completion_command_runner} - CompletionCommandRunner( + new( super.executableName, super.description, { super.usageLineLength, @@ -97,7 +97,7 @@ abstract class CompletionCommandRunner extends CommandRunner { tryInstallCompletionFiles(Level.error); } - return super.runCommand(topLevelResults); + return await super.runCommand(topLevelResults); } /// Tries to install completion files for the current shell. diff --git a/lib/src/installer/completion_configuration.dart b/lib/src/installer/completion_configuration.dart index a524450..b07abdc 100644 --- a/lib/src/installer/completion_configuration.dart +++ b/lib/src/installer/completion_configuration.dart @@ -20,14 +20,11 @@ typedef ShellCommandsMap = @immutable class CompletionConfiguration { /// {@macro completion_configuration} - const CompletionConfiguration._({ - required this.uninstalls, - required this.installs, - }); + const new _({required this.uninstalls, required this.installs}); /// Creates an empty [CompletionConfiguration]. @visibleForTesting - CompletionConfiguration.empty() + new empty() : uninstalls = ShellCommandsMap({}), installs = ShellCommandsMap({}); @@ -40,7 +37,7 @@ class CompletionConfiguration { /// file's content. This content is assumed to be a JSON string. The parsing /// is handled gracefully, so if the JSON is partially or fully invalid, it /// handles issues without throwing an [Exception]. - factory CompletionConfiguration.fromFile(File file) { + factory fromFile(File file) { if (!file.existsSync()) { return CompletionConfiguration.empty(); } @@ -50,7 +47,7 @@ class CompletionConfiguration { } /// Creates a [CompletionConfiguration] from the given JSON string. - factory CompletionConfiguration._fromJson(String json) { + factory _fromJson(String json) { late final Map decodedJson; try { decodedJson = jsonDecode(json) as Map; diff --git a/lib/src/installer/completion_installation.dart b/lib/src/installer/completion_installation.dart index 6b2fa40..4944ce9 100644 --- a/lib/src/installer/completion_installation.dart +++ b/lib/src/installer/completion_installation.dart @@ -13,7 +13,7 @@ import 'package:path/path.dart' as path; class CompletionInstallation { /// {@macro shell_completion_installation} @visibleForTesting - CompletionInstallation({ + new({ required this.configuration, required this.logger, required this.isWindows, @@ -30,7 +30,7 @@ class CompletionInstallation { /// /// Pass [environmentOverride] to override the default value of /// [Platform.environment]. - factory CompletionInstallation.fromSystemShell({ + factory fromSystemShell({ required SystemShell? systemShell, required Logger logger, bool? isWindowsOverride, diff --git a/lib/src/installer/exceptions.dart b/lib/src/installer/exceptions.dart index 583071f..b98778e 100644 --- a/lib/src/installer/exceptions.dart +++ b/lib/src/installer/exceptions.dart @@ -3,10 +3,7 @@ /// {@endtemplate} class CompletionInstallationException implements Exception { /// {@macro completion_installation_exception} - CompletionInstallationException({ - required this.message, - required this.rootCommand, - }); + new({required this.message, required this.rootCommand}); /// The error message for this exception final String message; @@ -25,10 +22,7 @@ class CompletionInstallationException implements Exception { /// {@endtemplate} class CompletionUninstallationException implements Exception { /// {@macro completion_unistallation_exception} - CompletionUninstallationException({ - required this.message, - required this.rootCommand, - }); + new({required this.message, required this.rootCommand}); /// The error message for this exception final String message; diff --git a/lib/src/installer/script_configuration_entry.dart b/lib/src/installer/script_configuration_entry.dart index b4c8c82..db27109 100644 --- a/lib/src/installer/script_configuration_entry.dart +++ b/lib/src/installer/script_configuration_entry.dart @@ -6,7 +6,7 @@ import 'dart:io'; /// {@endtemplate} class ScriptConfigurationEntry { /// {@macro script_entry} - const ScriptConfigurationEntry(this.name) + const new(this.name) : _startComment = '## [$name]', _endComment = '## [/$name]'; @@ -46,10 +46,7 @@ class ScriptConfigurationEntry { ..writeln(_endComment) ..writeln(); - file.writeAsStringSync( - stringBuffer.toString(), - mode: FileMode.append, - ); + file.writeAsStringSync(stringBuffer.toString(), mode: FileMode.append); } /// Removes the entry with [name] from the [file]. @@ -68,11 +65,7 @@ class ScriptConfigurationEntry { final stringPattern = '\n$_startComment.*$_endComment\n\n' .replaceAll('[', r'\[') .replaceAll(']', r'\]'); - final pattern = RegExp( - stringPattern, - multiLine: true, - dotAll: true, - ); + final pattern = RegExp(stringPattern, multiLine: true, dotAll: true); final newContent = content.replaceAllMapped(pattern, (_) => ''); file.writeAsStringSync(newContent); diff --git a/lib/src/installer/shell_completion_configuration.dart b/lib/src/installer/shell_completion_configuration.dart index bb099f2..a198083 100644 --- a/lib/src/installer/shell_completion_configuration.dart +++ b/lib/src/installer/shell_completion_configuration.dart @@ -20,7 +20,7 @@ typedef SourceStringTemplate = String Function(String scriptPath); @immutable class ShellCompletionConfiguration { /// {@macro shell_completion_configuration} - const ShellCompletionConfiguration._({ + const new _({ required this.shell, required this.shellRCFiles, required this.sourceLineTemplate, @@ -28,9 +28,7 @@ class ShellCompletionConfiguration { }); /// Creates a [ShellCompletionConfiguration] given the current [SystemShell]. - factory ShellCompletionConfiguration.fromSystemShell( - SystemShell systemShell, - ) { + factory fromSystemShell(SystemShell systemShell) { switch (systemShell) { case SystemShell.zsh: return zshConfiguration; diff --git a/lib/src/parser/completion_level.dart b/lib/src/parser/completion_level.dart index e80e9f2..66f56e8 100644 --- a/lib/src/parser/completion_level.dart +++ b/lib/src/parser/completion_level.dart @@ -16,7 +16,7 @@ import 'package:meta/meta.dart'; class CompletionLevel { /// {@macro completion_level} @visibleForTesting - const CompletionLevel({ + const new({ required this.grammar, required this.rawArgs, required this.visibleSubcommands, diff --git a/lib/src/parser/completion_result.dart b/lib/src/parser/completion_result.dart index 378c283..e9ef9c7 100644 --- a/lib/src/parser/completion_result.dart +++ b/lib/src/parser/completion_result.dart @@ -19,7 +19,7 @@ import 'package:meta/meta.dart'; @immutable abstract class CompletionResult { /// {@macro completion_result} - const CompletionResult(); + const new(); /// A collection of [MapEntry] with completion suggestions to their /// descriptions. @@ -32,9 +32,7 @@ abstract class CompletionResult { /// {@endtemplate} class AllOptionsAndCommandsCompletionResult extends CompletionResult { /// {@macro all_options_and_commands_completion_result} - const AllOptionsAndCommandsCompletionResult({ - required this.completionLevel, - }); + const new({required this.completionLevel}); /// The [CompletionLevel] in which the suggested options and subcommands are /// supposed to be located at. @@ -65,9 +63,7 @@ class AllOptionsAndCommandsCompletionResult extends CompletionResult { /// - [AllOptionsAndCommandsCompletionResult] class AllAbbrOptionsCompletionResult extends CompletionResult { /// {@macro all_options_and_commands_completion_result} - const AllAbbrOptionsCompletionResult({ - required this.completionLevel, - }); + const new({required this.completionLevel}); /// The [CompletionLevel] in which the suggested options and subcommands are /// supposed to be located at. @@ -94,10 +90,7 @@ class AllAbbrOptionsCompletionResult extends CompletionResult { /// If a command doesnt match the pattern, its aliases are also checked. class MatchingCommandsCompletionResult extends CompletionResult { /// {@macro matching_commands_completion_result} - const MatchingCommandsCompletionResult({ - required this.completionLevel, - required this.pattern, - }); + const new({required this.completionLevel, required this.pattern}); /// The [CompletionLevel] in which the suggested commands are supposed to be /// located at. @@ -133,10 +126,7 @@ class MatchingCommandsCompletionResult extends CompletionResult { /// If an option does not match the pattern, its aliases will be checked. class MatchingOptionsCompletionResult extends CompletionResult { /// {@macro matching_options_completion_result} - const MatchingOptionsCompletionResult({ - required this.completionLevel, - required this.pattern, - }); + const new({required this.completionLevel, required this.pattern}); /// The [CompletionLevel] in which the suggested options are supposed to be /// located at. @@ -191,7 +181,7 @@ class MatchingOptionsCompletionResult extends CompletionResult { /// in an abbreviated form. class OptionValuesCompletionResult extends CompletionResult { /// {@macro option_values_completion_result} - const OptionValuesCompletionResult({ + const new({ required this.completionLevel, required this.optionName, this.pattern, @@ -199,7 +189,7 @@ class OptionValuesCompletionResult extends CompletionResult { includeAbbrName = false; /// {@macro option_values_completion_result} - const OptionValuesCompletionResult.abbr({ + const new abbr({ required this.completionLevel, required String abbrName, this.pattern, diff --git a/lib/src/parser/completion_state.dart b/lib/src/parser/completion_state.dart index 13909f3..06a602a 100644 --- a/lib/src/parser/completion_state.dart +++ b/lib/src/parser/completion_state.dart @@ -15,7 +15,7 @@ import 'package:meta/meta.dart'; class CompletionState extends Equatable { /// {@macro completion_state} @visibleForTesting - const CompletionState({ + const new({ required this.cword, required this.point, required this.line, diff --git a/lib/src/parser/parser.dart b/lib/src/parser/parser.dart index 0e5bb8f..45bd109 100644 --- a/lib/src/parser/parser.dart +++ b/lib/src/parser/parser.dart @@ -11,9 +11,7 @@ import 'package:cli_completion/src/parser/arg_parser_extension.dart'; /// {@endtemplate} class CompletionParser { /// {@macro completion_parser} - CompletionParser({ - required this.completionLevel, - }); + new({required this.completionLevel}); /// The [CompletionLevel] to parse. final CompletionLevel completionLevel; diff --git a/lib/src/system_shell.dart b/lib/src/system_shell.dart index ec744c7..49b359b 100644 --- a/lib/src/system_shell.dart +++ b/lib/src/system_shell.dart @@ -15,7 +15,7 @@ enum SystemShell { bash('bash'); /// {@macro system_shell} - const SystemShell(this.name); + new(this.name); /// A descriptive string to identify the shell among others. final String name; @@ -26,9 +26,7 @@ enum SystemShell { /// [Platform.environment]. /// /// Based on https://stackoverflow.com/a/3327022 - static SystemShell? current({ - Map? environmentOverride, - }) { + static SystemShell? current({Map? environmentOverride}) { final environment = environmentOverride ?? Platform.environment; // Heuristic: if ZSH_NAME is set, must be zsh diff --git a/pubspec.yaml b/pubspec.yaml index 0b76929..12a8316 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -21,4 +21,4 @@ dependencies: dev_dependencies: mocktail: ^1.0.4 test: ^1.25.8 - very_good_analysis: ">=10.3.0 <12.0.0" + very_good_analysis: ^11.0.0 diff --git a/test/src/command_runner/commands/handle_completion_command_test.dart b/test/src/command_runner/commands/handle_completion_command_test.dart index 5d9c3e6..a231a07 100644 --- a/test/src/command_runner/commands/handle_completion_command_test.dart +++ b/test/src/command_runner/commands/handle_completion_command_test.dart @@ -4,14 +4,11 @@ import 'package:mason_logger/mason_logger.dart'; import 'package:mocktail/mocktail.dart'; import 'package:test/test.dart'; -class MockLogger extends Mock implements Logger {} +class MockLogger extends Mock implements Logger; class _TestCompletionCommandRunner extends CompletionCommandRunner { - _TestCompletionCommandRunner() : super('test', 'Test command runner') { - final subCommand = _TestCommand( - name: 'subcommand', - description: 'level 1', - ); + new() : super('test', 'Test command runner') { + final subCommand = _TestCommand(name: 'subcommand', description: 'level 1'); addCommand(subCommand); final subSubCommand = _TestCommand( name: 'subsubcommand2', @@ -30,10 +27,7 @@ class _TestCompletionCommandRunner extends CompletionCommandRunner { } class _TestCommand extends Command { - _TestCommand({ - required this.name, - required this.description, - }); + new({required this.name, required this.description}); @override final String description; diff --git a/test/src/command_runner/commands/install_completion_files_command_test.dart b/test/src/command_runner/commands/install_completion_files_command_test.dart index c64eb4d..d4b6830 100644 --- a/test/src/command_runner/commands/install_completion_files_command_test.dart +++ b/test/src/command_runner/commands/install_completion_files_command_test.dart @@ -4,13 +4,13 @@ import 'package:mason_logger/mason_logger.dart'; import 'package:mocktail/mocktail.dart'; import 'package:test/test.dart'; -class _MockLogger extends Mock implements Logger {} +class _MockLogger extends Mock implements Logger; class _MockCompletionInstallation extends Mock - implements CompletionInstallation {} + implements CompletionInstallation; class _TestCompletionCommandRunner extends CompletionCommandRunner { - _TestCompletionCommandRunner() : super('test', 'Test command runner'); + new() : super('test', 'Test command runner'); @override // Override acceptable for test files @@ -68,12 +68,10 @@ void main() { test('when verbose', () async { await commandRunner.run(['install-completion-files', '--verbose']); - verify( - () { - return commandRunner.completionInstallationLogger.level = - Level.verbose; - }, - ).called(1); + verify(() { + return commandRunner.completionInstallationLogger.level = + Level.verbose; + }).called(1); }); }); }); diff --git a/test/src/command_runner/commands/print_completion_script_command_test.dart b/test/src/command_runner/commands/print_completion_script_command_test.dart index f2a84ab..2c94445 100644 --- a/test/src/command_runner/commands/print_completion_script_command_test.dart +++ b/test/src/command_runner/commands/print_completion_script_command_test.dart @@ -4,13 +4,13 @@ import 'package:mason_logger/mason_logger.dart'; import 'package:mocktail/mocktail.dart'; import 'package:test/test.dart'; -class _MockLogger extends Mock implements Logger {} +class _MockLogger extends Mock implements Logger; class _MockCompletionInstallation extends Mock - implements CompletionInstallation {} + implements CompletionInstallation; class _TestCompletionCommandRunner extends CompletionCommandRunner { - _TestCompletionCommandRunner() : super('test', 'Test command runner'); + new() : super('test', 'Test command runner'); @override bool get enableAutoInstall => false; @@ -84,28 +84,23 @@ void main() { await commandRunner.run(['completion-script']); - verify( - () => commandRunner.completionInstallationLogger.warn(any()), - ).called(1); + verify(() => commandRunner.completionInstallationLogger.warn(any())) + .called(1); }, ); - test( - 'logs an error when an unknown exception happens', - () async { - when( - () => commandRunner.completionInstallation.completionScriptFor( - commandRunner.executableName, - ), - ).thenThrow(Exception('oops')); + test('logs an error when an unknown exception happens', () async { + when( + () => commandRunner.completionInstallation.completionScriptFor( + commandRunner.executableName, + ), + ).thenThrow(Exception('oops')); - await commandRunner.run(['completion-script']); + await commandRunner.run(['completion-script']); - verify( - () => commandRunner.completionInstallationLogger.err(any()), - ).called(1); - }, - ); + verify(() => commandRunner.completionInstallationLogger.err(any())) + .called(1); + }); }); }); } diff --git a/test/src/command_runner/commands/uninstall_completion_files_command_test.dart b/test/src/command_runner/commands/uninstall_completion_files_command_test.dart index e771a89..4896421 100644 --- a/test/src/command_runner/commands/uninstall_completion_files_command_test.dart +++ b/test/src/command_runner/commands/uninstall_completion_files_command_test.dart @@ -4,13 +4,13 @@ import 'package:mason_logger/mason_logger.dart'; import 'package:mocktail/mocktail.dart'; import 'package:test/test.dart'; -class _MockLogger extends Mock implements Logger {} +class _MockLogger extends Mock implements Logger; class _MockCompletionInstallation extends Mock - implements CompletionInstallation {} + implements CompletionInstallation; class _TestCompletionCommandRunner extends CompletionCommandRunner { - _TestCompletionCommandRunner() : super('test', 'Test command runner'); + new() : super('test', 'Test command runner'); @override // Override acceptable for test files @@ -62,12 +62,10 @@ void main() { test('when verbose', () async { await commandRunner.run(['uninstall-completion-files', '--verbose']); - verify( - () { - return commandRunner.completionInstallationLogger.level = - Level.verbose; - }, - ).called(1); + verify(() { + return commandRunner.completionInstallationLogger.level = + Level.verbose; + }).called(1); verify( () => commandRunner.completionInstallation.uninstall( commandRunner.executableName, diff --git a/test/src/command_runner/completion_command_runner_test.dart b/test/src/command_runner/completion_command_runner_test.dart index 7968dd0..5dafb79 100644 --- a/test/src/command_runner/completion_command_runner_test.dart +++ b/test/src/command_runner/completion_command_runner_test.dart @@ -6,13 +6,13 @@ import 'package:mason_logger/mason_logger.dart'; import 'package:mocktail/mocktail.dart'; import 'package:test/test.dart'; -class MockLogger extends Mock implements Logger {} +class MockLogger extends Mock implements Logger; class _MockCompletionInstallation extends Mock - implements CompletionInstallation {} + implements CompletionInstallation; class _TestCompletionCommandRunner extends CompletionCommandRunner { - _TestCompletionCommandRunner() : super('test', 'Test command runner'); + new() : super('test', 'Test command runner'); @override bool enableAutoInstall = true; @@ -36,8 +36,7 @@ class _TestCompletionCommandRunner extends CompletionCommandRunner { class _TestNoAutoInstallCompletionCommandRunner extends CompletionCommandRunner { - _TestNoAutoInstallCompletionCommandRunner() - : super('test', 'Test command runner'); + new() : super('test', 'Test command runner'); @override bool get enableAutoInstall => false; @@ -57,7 +56,7 @@ class _TestUserCommand extends Command { } class _TestCompletionResult extends CompletionResult { - const _TestCompletionResult(this._completions); + const new(this._completions); final Map _completions; @@ -80,27 +79,16 @@ void main() { final commandRunner = _TestCompletionCommandRunner() ..addCommand(_TestUserCommand()); - expect( - commandRunner.usage, - contains('ahoy'), - ); - expect( - commandRunner.usage, - isNot(contains('install-completion-files')), - ); - expect( - commandRunner.usage, - isNot(contains('completion')), - ); + expect(commandRunner.usage, contains('ahoy')); + expect(commandRunner.usage, isNot(contains('install-completion-files'))); + expect(commandRunner.usage, isNot(contains('completion'))); }); group('completionInstallation', () { // test if it gets one with the current system shell test('creates one with the given system shell', () { final commandRunner = _TestCompletionCommandRunner() - ..environmentOverride = { - 'SHELL': '/foo/bar/zsh', - }; + ..environmentOverride = {'SHELL': '/foo/bar/zsh'}; expect( commandRunner.completionInstallation, isA().having( @@ -116,37 +104,25 @@ void main() { final commandRunner = _TestCompletionCommandRunner(); expect( commandRunner.commands.keys, - containsAll([ - 'completion', - 'install-completion-files', - ]), + containsAll(['completion', 'install-completion-files']), ); }); group('print completion script command', () { - test( - 'is not added when auto install is enabled', - () { - final commandRunner = _TestCompletionCommandRunner(); - - expect( - commandRunner.commands.keys, - isNot(contains('completion-script')), - ); - }, - ); + test('is not added when auto install is enabled', () { + final commandRunner = _TestCompletionCommandRunner(); - test( - 'is added when auto install is disabled', - () { - final commandRunner = _TestNoAutoInstallCompletionCommandRunner(); - - expect( - commandRunner.commands.keys, - contains('completion-script'), - ); - }, - ); + expect( + commandRunner.commands.keys, + isNot(contains('completion-script')), + ); + }); + + test('is added when auto install is disabled', () { + final commandRunner = _TestNoAutoInstallCompletionCommandRunner(); + + expect(commandRunner.commands.keys, contains('completion-script')); + }); }); group('auto install', () { @@ -157,9 +133,8 @@ void main() { await commandRunner.run(['ahoy']); - verify( - () => commandRunner.completionInstallation.install('test'), - ).called(1); + verify(() => commandRunner.completionInstallation.install('test')) + .called(1); verify( () => commandRunner.completionInstallationLogger.level = Level.error, ).called(1); @@ -185,9 +160,7 @@ void main() { ..enableAutoInstall = true ..addCommand(_TestUserCommand()) ..mockCompletionInstallation = _MockCompletionInstallation() - ..environmentOverride = { - 'SHELL': '/foo/bar/zsh', - }; + ..environmentOverride = {'SHELL': '/foo/bar/zsh'}; await commandRunner.run(['ahoy']); @@ -214,9 +187,8 @@ void main() { await commandRunner.run(['ahoy']); - verify( - () => commandRunner.completionInstallationLogger.warn(any()), - ).called(1); + verify(() => commandRunner.completionInstallationLogger.warn(any())) + .called(1); }, ); @@ -227,15 +199,13 @@ void main() { ..addCommand(_TestUserCommand()) ..mockCompletionInstallation = _MockCompletionInstallation(); - when( - () => commandRunner.completionInstallation.install('test'), - ).thenThrow(Exception('oops')); + when(() => commandRunner.completionInstallation.install('test')) + .thenThrow(Exception('oops')); await commandRunner.run(['ahoy']); - verify( - () => commandRunner.completionInstallationLogger.err(any()), - ).called(1); + verify(() => commandRunner.completionInstallationLogger.err(any())) + .called(1); }, ); @@ -246,20 +216,18 @@ void main() { final commandRunner = _TestCompletionCommandRunner() ..mockCompletionInstallation = _MockCompletionInstallation(); - when( - () => commandRunner.completionInstallation.uninstall('test'), - ).thenThrow( - CompletionUninstallationException( - message: 'oops', - rootCommand: 'test', - ), - ); + when(() => commandRunner.completionInstallation.uninstall('test')) + .thenThrow( + CompletionUninstallationException( + message: 'oops', + rootCommand: 'test', + ), + ); commandRunner.tryUninstallCompletionFiles(Level.verbose); - verify( - () => commandRunner.completionInstallationLogger.warn(any()), - ).called(1); + verify(() => commandRunner.completionInstallationLogger.warn(any())) + .called(1); }, ); @@ -269,15 +237,13 @@ void main() { final commandRunner = _TestCompletionCommandRunner() ..mockCompletionInstallation = _MockCompletionInstallation(); - when( - () => commandRunner.completionInstallation.uninstall('test'), - ).thenThrow(Exception('oops')); + when(() => commandRunner.completionInstallation.uninstall('test')) + .thenThrow(Exception('oops')); commandRunner.tryUninstallCompletionFiles(Level.verbose); - verify( - () => commandRunner.completionInstallationLogger.err(any()), - ).called(1); + verify(() => commandRunner.completionInstallationLogger.err(any())) + .called(1); }, ); }); @@ -292,9 +258,7 @@ void main() { }); final commandRunner = _TestCompletionCommandRunner() - ..environmentOverride = { - 'SHELL': '/foo/bar/zsh', - }; + ..environmentOverride = {'SHELL': '/foo/bar/zsh'}; final output = StringBuffer(); when(() { @@ -322,9 +286,7 @@ suggestion4:description4 }); final commandRunner = _TestCompletionCommandRunner() - ..environmentOverride = { - 'SHELL': '/foo/bar/bash', - }; + ..environmentOverride = {'SHELL': '/foo/bar/bash'}; final output = StringBuffer(); when(() { diff --git a/test/src/installer/completion_configuration_test.dart b/test/src/installer/completion_configuration_test.dart index 147f2dc..308e093 100644 --- a/test/src/installer/completion_configuration_test.dart +++ b/test/src/installer/completion_configuration_test.dart @@ -24,11 +24,7 @@ void main() { addTearDown(() => tempDirectory.deleteSync(recursive: true)); final file = File(path.join(tempDirectory.path, 'config.json')); - expect( - file.existsSync(), - isFalse, - reason: 'File should not exist', - ); + expect(file.existsSync(), isFalse, reason: 'File should not exist'); final completionConfiguration = CompletionConfiguration.fromFile( file, @@ -176,11 +172,7 @@ void main() { addTearDown(() => tempDirectory.deleteSync(recursive: true)); final file = File(path.join(tempDirectory.path, 'config.json')); - expect( - file.existsSync(), - isFalse, - reason: 'File should not exist', - ); + expect(file.existsSync(), isFalse, reason: 'File should not exist'); CompletionConfiguration.empty().writeTo(file); @@ -197,11 +189,7 @@ void main() { final file = File(path.join(tempDirectory.path, 'config.json')) ..createSync(); - expect( - file.existsSync(), - isTrue, - reason: 'File should exist', - ); + expect(file.existsSync(), isTrue, reason: 'File should exist'); expect( () => CompletionConfiguration.empty().writeTo(file), diff --git a/test/src/installer/completion_installation_test.dart b/test/src/installer/completion_installation_test.dart index 666f2be..91bec58 100644 --- a/test/src/installer/completion_installation_test.dart +++ b/test/src/installer/completion_installation_test.dart @@ -7,7 +7,7 @@ import 'package:mocktail/mocktail.dart'; import 'package:path/path.dart' as path; import 'package:test/test.dart'; -class MockLogger extends Mock implements Logger {} +class MockLogger extends Mock implements Logger; void main() { late Logger logger; @@ -63,9 +63,7 @@ void main() { configuration: zshConfiguration, logger: logger, isWindows: true, - environment: { - 'LOCALAPPDATA': tempDir.path, - }, + environment: {'LOCALAPPDATA': tempDir.path}, ); expect( @@ -80,10 +78,7 @@ void main() { configuration: zshConfiguration, logger: logger, isWindows: false, - environment: { - 'XDG_CONFIG_HOME': tempDir.path, - 'HOME': 'ooohnoooo', - }, + environment: {'XDG_CONFIG_HOME': tempDir.path, 'HOME': 'ooohnoooo'}, ); expect( @@ -97,9 +92,7 @@ void main() { configuration: zshConfiguration, logger: logger, isWindows: false, - environment: { - 'HOME': tempDir.path, - }, + environment: {'HOME': tempDir.path}, ); expect( @@ -116,9 +109,7 @@ void main() { configuration: zshConfiguration, logger: logger, isWindows: false, - environment: { - 'HOME': tempDir.path, - }, + environment: {'HOME': tempDir.path}, ); expect( @@ -130,9 +121,7 @@ void main() { configuration: bashConfiguration, logger: logger, isWindows: false, - environment: { - 'HOME': tempDir.path, - }, + environment: {'HOME': tempDir.path}, ); expect( @@ -166,9 +155,7 @@ void main() { configuration: zshConfiguration, logger: logger, isWindows: false, - environment: { - 'HOME': tempDir.path, - }, + environment: {'HOME': tempDir.path}, ); expect(installation.completionConfigDir.existsSync(), false); @@ -178,25 +165,15 @@ void main() { expect(installation.completionConfigDir.existsSync(), true); verifyNever( - () => logger.warn( - any( - that: endsWith( - 'directory was already found.', - ), - ), - ), + () => + logger.warn(any(that: endsWith('directory was already found.'))), ); installation.createCompletionConfigDir(); verify( - () => logger.warn( - any( - that: endsWith( - 'directory was already found.', - ), - ), - ), + () => + logger.warn(any(that: endsWith('directory was already found.'))), ).called(1); }); @@ -204,9 +181,7 @@ void main() { final installation = CompletionInstallation( logger: logger, isWindows: false, - environment: { - 'HOME': tempDir.path, - }, + environment: {'HOME': tempDir.path}, configuration: zshConfiguration, ); @@ -256,9 +231,7 @@ void main() { final installation = CompletionInstallation( logger: logger, isWindows: false, - environment: { - 'HOME': tempDir.path, - }, + environment: {'HOME': tempDir.path}, configuration: zshConfiguration, ); @@ -285,11 +258,7 @@ void main() { verify( () => logger.info( - any( - that: startsWith( - 'No file found at ${configFile.path}', - ), - ), + any(that: startsWith('No file found at ${configFile.path}')), ), ).called(1); @@ -310,9 +279,7 @@ void main() { final installation = CompletionInstallation( logger: logger, isWindows: false, - environment: { - 'HOME': tempDir.path, - }, + environment: {'HOME': tempDir.path}, configuration: zshConfiguration, ); @@ -345,81 +312,70 @@ void main() { '''); }); - test( - 'installs completion for a an already installed command when forced', - () { - final installation = CompletionInstallation( - logger: logger, - isWindows: false, - environment: { - 'HOME': tempDir.path, - }, - configuration: zshConfiguration, - ); + test('''installs completion for a an already installed command when forced''', () { + final installation = CompletionInstallation( + logger: logger, + isWindows: false, + environment: {'HOME': tempDir.path}, + configuration: zshConfiguration, + ); - File(path.join(tempDir.path, '.zshrc')).createSync(); + File(path.join(tempDir.path, '.zshrc')).createSync(); - installation.install('very_good'); + installation.install('very_good'); - verify(() => logger.level = Level.info).called(1); + verify(() => logger.level = Level.info).called(1); - verify( - () => logger.info( - '\n' - 'Completion files installed. To enable completion, run the ' - 'following command in your shell:\n' - 'source ${path.join(tempDir.path, '.zshrc')}\n', - ), - ).called(1); + verify( + () => logger.info( + '\n' + 'Completion files installed. To enable completion, run the ' + 'following command in your shell:\n' + 'source ${path.join(tempDir.path, '.zshrc')}\n', + ), + ).called(1); - reset(logger); + reset(logger); - // install again - installation.install('very_good', force: true); + // install again + installation.install('very_good', force: true); - verify( - () => logger.warn( - 'A ${installation.completionConfigDir.path} directory was already' - ' found.', - ), - ).called(1); - verify( - () => logger.warn( - 'A script file for very_good was already found on ${path.join( - installation.completionConfigDir.path, - 'very_good.zsh', - )}.', - ), - ).called(1); - verify( - () => logger.warn( - 'A config entry for very_good was already found on ' - '${path.join( - installation.completionConfigDir.path, - 'zsh-config.zsh', - )}.', - ), - ).called(1); + verify( + () => logger.warn( + 'A ${installation.completionConfigDir.path} directory was already' + ' found.', + ), + ).called(1); + verify( + () => logger.warn( + '''A script file for very_good was already found on ${path.join(installation.completionConfigDir.path, 'very_good.zsh')}.''', + ), + ).called(1); + verify( + () => logger.warn( + 'A config entry for very_good was already found on ' + '''${path.join(installation.completionConfigDir.path, 'zsh-config.zsh')}.''', + ), + ).called(1); - verify( - () => logger.warn( - 'A completion config entry was already found on ' - '${path.join(tempDir.path, '.zshrc')}.', - ), - ).called(1); + verify( + () => logger.warn( + 'A completion config entry was already found on ' + '${path.join(tempDir.path, '.zshrc')}.', + ), + ).called(1); - verifyNever(() => logger.level = Level.debug); + verifyNever(() => logger.level = Level.debug); - verifyNever( - () => logger.info( - '\n' - 'Completion files installed. To enable completion, run the ' - 'following command in your shell:\n' - 'source ${path.join(tempDir.path, '.zshrc')}\n', - ), - ); - }, - ); + verifyNever( + () => logger.info( + '\n' + 'Completion files installed. To enable completion, run the ' + 'following command in your shell:\n' + 'source ${path.join(tempDir.path, '.zshrc')}\n', + ), + ); + }); test( '''avoid installing completion for an already installed command''', @@ -427,9 +383,7 @@ void main() { final installation = CompletionInstallation( logger: logger, isWindows: false, - environment: { - 'HOME': tempDir.path, - }, + environment: {'HOME': tempDir.path}, configuration: zshConfiguration, ); @@ -460,30 +414,26 @@ void main() { }, ); - test( - 'installing completion for two different commands', - () { - final zshInstallation = CompletionInstallation( - logger: logger, - isWindows: false, - environment: { - 'HOME': tempDir.path, - }, - configuration: zshConfiguration, - ); + test('installing completion for two different commands', () { + final zshInstallation = CompletionInstallation( + logger: logger, + isWindows: false, + environment: {'HOME': tempDir.path}, + configuration: zshConfiguration, + ); - final rcFile = File(path.join(tempDir.path, '.zshrc'))..createSync(); + final rcFile = File(path.join(tempDir.path, '.zshrc'))..createSync(); - final configDir = zshInstallation.completionConfigDir; + final configDir = zshInstallation.completionConfigDir; - zshInstallation - ..install('very_good') - ..install('not_good'); + zshInstallation + ..install('very_good') + ..install('not_good'); - // rc fle includes one reference to the global config + // rc fle includes one reference to the global config - // Different format needed for matching cli output - expect(rcFile.readAsStringSync(), ''' + // Different format needed for matching cli output + expect(rcFile.readAsStringSync(), ''' \n## [Completion] ## Completion scripts setup. Remove the following line to uninstall [[ -f ${configDir.path}/zsh-config.zsh ]] && . ${configDir.path}/zsh-config.zsh || true @@ -491,13 +441,11 @@ void main() { '''); - // global config includes one reference for each command - final globalConfig = File( - path.join(configDir.path, 'zsh-config.zsh'), - ); + // global config includes one reference for each command + final globalConfig = File(path.join(configDir.path, 'zsh-config.zsh')); - // Different format needed for matching cli output - expect(globalConfig.readAsStringSync(), ''' + // Different format needed for matching cli output + expect(globalConfig.readAsStringSync(), ''' \n## [very_good] ## Completion config for "very_good" [[ -f ${configDir.path}/very_good.zsh ]] && . ${configDir.path}/very_good.zsh || true @@ -510,34 +458,32 @@ void main() { '''); - expect( - configDir.listSync().map((e) => path.basename(e.path)), - unorderedEquals([ - 'not_good.zsh', - 'very_good.zsh', - 'zsh-config.zsh', - 'config.json', - ]), - ); + expect( + configDir.listSync().map((e) => path.basename(e.path)), + unorderedEquals([ + 'not_good.zsh', + 'very_good.zsh', + 'zsh-config.zsh', + 'config.json', + ]), + ); - final bashInstallation = CompletionInstallation( - logger: logger, - isWindows: false, - environment: { - 'HOME': tempDir.path, - }, - configuration: bashConfiguration, - ); + final bashInstallation = CompletionInstallation( + logger: logger, + isWindows: false, + environment: {'HOME': tempDir.path}, + configuration: bashConfiguration, + ); - final bashProfile = File(path.join(tempDir.path, '.bash_profile')) - ..createSync(); + final bashProfile = File(path.join(tempDir.path, '.bash_profile')) + ..createSync(); - bashInstallation - ..install('very_good') - ..install('not_good'); + bashInstallation + ..install('very_good') + ..install('not_good'); - // Different format needed for matching cli output - expect(bashProfile.readAsStringSync(), ''' + // Different format needed for matching cli output + expect(bashProfile.readAsStringSync(), ''' \n## [Completion] ## Completion scripts setup. Remove the following line to uninstall [ -f ${configDir.path}/bash-config.bash ] && . ${configDir.path}/bash-config.bash || true @@ -545,45 +491,39 @@ void main() { '''); - expect( - configDir.listSync().map((e) => path.basename(e.path)), - unorderedEquals([ - 'not_good.bash', - 'not_good.zsh', - 'very_good.bash', - 'very_good.zsh', - 'zsh-config.zsh', - 'bash-config.bash', - 'config.json', - ]), - ); - }, - ); + expect( + configDir.listSync().map((e) => path.basename(e.path)), + unorderedEquals([ + 'not_good.bash', + 'not_good.zsh', + 'very_good.bash', + 'very_good.zsh', + 'zsh-config.zsh', + 'bash-config.bash', + 'config.json', + ]), + ); + }); - test( - 'installing completion when the current shell is not supported', - () { - final installation = CompletionInstallation.fromSystemShell( - logger: logger, - isWindowsOverride: false, - environmentOverride: { - 'HOME': tempDir.path, - }, - systemShell: null, - ); + test('installing completion when the current shell is not supported', () { + final installation = CompletionInstallation.fromSystemShell( + logger: logger, + isWindowsOverride: false, + environmentOverride: {'HOME': tempDir.path}, + systemShell: null, + ); - expect( - () => installation.install('very_good'), - throwsA( - isA().having( - (e) => e.message, - 'message', - 'Unknown shell.', - ), + expect( + () => installation.install('very_good'), + throwsA( + isA().having( + (e) => e.message, + 'message', + 'Unknown shell.', ), - ); - }, - ); + ), + ); + }); test( '''doesn't remove command from $CompletionConfiguration uninstalls when not forced to install''', @@ -592,9 +532,7 @@ void main() { final installation = CompletionInstallation.fromSystemShell( logger: logger, isWindowsOverride: false, - environmentOverride: { - 'HOME': tempDir.path, - }, + environmentOverride: {'HOME': tempDir.path}, systemShell: systemShell, ); @@ -645,9 +583,7 @@ void main() { final installation = CompletionInstallation.fromSystemShell( logger: logger, isWindowsOverride: false, - environmentOverride: { - 'HOME': tempDir.path, - }, + environmentOverride: {'HOME': tempDir.path}, systemShell: systemShell, ); @@ -698,9 +634,7 @@ void main() { final installation = CompletionInstallation.fromSystemShell( logger: logger, isWindowsOverride: false, - environmentOverride: { - 'HOME': tempDir.path, - }, + environmentOverride: {'HOME': tempDir.path}, systemShell: systemShell, ); @@ -731,9 +665,7 @@ void main() { final installation = CompletionInstallation.fromSystemShell( logger: logger, isWindowsOverride: false, - environmentOverride: { - 'HOME': tempDir.path, - }, + environmentOverride: {'HOME': tempDir.path}, systemShell: systemShell, ); @@ -771,352 +703,311 @@ void main() { }, ); - test( - 'installing completion for .bashrc', - () { - final bashInstallation = CompletionInstallation( - logger: logger, - isWindows: false, - environment: { - 'HOME': tempDir.path, - }, - configuration: bashConfiguration, - ); + test('installing completion for .bashrc', () { + final bashInstallation = CompletionInstallation( + logger: logger, + isWindows: false, + environment: {'HOME': tempDir.path}, + configuration: bashConfiguration, + ); - final configDir = bashInstallation.completionConfigDir; + final configDir = bashInstallation.completionConfigDir; - final bashProfile = File(path.join(tempDir.path, '.bash_profile')) - ..createSync(); + final bashProfile = File(path.join(tempDir.path, '.bash_profile')) + ..createSync(); - bashInstallation.install('very_good'); + bashInstallation.install('very_good'); - // Different format needed for matching cli output - expect(bashProfile.readAsStringSync(), ''' + // Different format needed for matching cli output + expect(bashProfile.readAsStringSync(), ''' \n## [Completion] ## Completion scripts setup. Remove the following line to uninstall [ -f ${configDir.path}/bash-config.bash ] && . ${configDir.path}/bash-config.bash || true ## [/Completion] '''); - }, - ); + }); - test( - 'installing completion for .bash_profile', - () { - final bashInstallation = CompletionInstallation( - logger: logger, - isWindows: false, - environment: { - 'HOME': tempDir.path, - }, - configuration: bashConfiguration, - ); + test('installing completion for .bash_profile', () { + final bashInstallation = CompletionInstallation( + logger: logger, + isWindows: false, + environment: {'HOME': tempDir.path}, + configuration: bashConfiguration, + ); - final configDir = bashInstallation.completionConfigDir; + final configDir = bashInstallation.completionConfigDir; - final bashRc = File(path.join(tempDir.path, '.bashrc'))..createSync(); + final bashRc = File(path.join(tempDir.path, '.bashrc'))..createSync(); - bashInstallation.install('very_good'); + bashInstallation.install('very_good'); - // Different format needed for matching cli output - expect(bashRc.readAsStringSync(), ''' + // Different format needed for matching cli output + expect(bashRc.readAsStringSync(), ''' \n## [Completion] ## Completion scripts setup. Remove the following line to uninstall [ -f ${configDir.path}/bash-config.bash ] && . ${configDir.path}/bash-config.bash || true ## [/Completion] '''); - }, - ); + }); - test( - 'missing .bashrc and .bash_profile', - () { - final bashInstallation = CompletionInstallation( - logger: logger, - isWindows: false, - environment: { - 'HOME': tempDir.path, - }, - configuration: bashConfiguration, - ); + test('missing .bashrc and .bash_profile', () { + final bashInstallation = CompletionInstallation( + logger: logger, + isWindows: false, + environment: {'HOME': tempDir.path}, + configuration: bashConfiguration, + ); - expect( - () => bashInstallation.install('very_good'), - throwsA( - isA().having( - (e) => e.message, - 'message', - 'No configuration files where found at ' - '\n ${path.join(tempDir.path, '.bashrc')}' - '\n ${path.join(tempDir.path, '.bash_profile')}', - ), + expect( + () => bashInstallation.install('very_good'), + throwsA( + isA().having( + (e) => e.message, + 'message', + 'No configuration files where found at ' + '\n ${path.join(tempDir.path, '.bashrc')}' + '\n ${path.join(tempDir.path, '.bash_profile')}', ), - ); - }, - ); + ), + ); + }); }); group('uninstall', () { - test( - '''deletes entire completion configuration when there is a single command''', - () { - final tempDirectory = Directory.systemTemp.createTempSync(); - addTearDown(() => tempDirectory.deleteSync(recursive: true)); - - final configuration = zshConfiguration; - final rcFile = File(path.join(tempDirectory.path, '.zshrc')) - ..createSync(); - - const rootCommand = 'very_good'; - final installation = - CompletionInstallation( - logger: logger, - isWindows: false, - environment: { - 'HOME': tempDirectory.path, - }, - configuration: configuration, - ) - ..install(rootCommand) - ..uninstall(rootCommand); + test('''deletes entire completion configuration when there is a single command''', () { + final tempDirectory = Directory.systemTemp.createTempSync(); + addTearDown(() => tempDirectory.deleteSync(recursive: true)); + + final configuration = zshConfiguration; + final rcFile = File(path.join(tempDirectory.path, '.zshrc')) + ..createSync(); + + const rootCommand = 'very_good'; + final installation = + CompletionInstallation( + logger: logger, + isWindows: false, + environment: {'HOME': tempDirectory.path}, + configuration: configuration, + ) + ..install(rootCommand) + ..uninstall(rootCommand); - expect( - rcFile.existsSync(), - isTrue, - reason: 'RC file should not be deleted.', - ); - expect( - const ScriptConfigurationEntry('Completion').existsIn(rcFile), - isFalse, - reason: 'Completion config entry should be removed from RC file.', - ); - expect(installation.completionConfigDir.existsSync(), isFalse); - }, - ); - - test( - '''only deletes shell configuration when there is a single command in multiple shells''', - () { - final tempDirectory = Directory.systemTemp.createTempSync(); - addTearDown(() => tempDirectory.deleteSync(recursive: true)); - - final zshConfig = zshConfiguration; - final zshRCFile = File(path.join(tempDirectory.path, '.zshrc')) - ..createSync(); - - final bashConfig = bashConfiguration; - final bashRCFile = File( - path.join(tempDirectory.path, '.bash_profile'), - )..createSync(); + expect( + rcFile.existsSync(), + isTrue, + reason: 'RC file should not be deleted.', + ); + expect( + const ScriptConfigurationEntry('Completion').existsIn(rcFile), + isFalse, + reason: 'Completion config entry should be removed from RC file.', + ); + expect(installation.completionConfigDir.existsSync(), isFalse); + }); - const rootCommand = 'very_good'; + test('''only deletes shell configuration when there is a single command in multiple shells''', () { + final tempDirectory = Directory.systemTemp.createTempSync(); + addTearDown(() => tempDirectory.deleteSync(recursive: true)); - final bashInstallation = CompletionInstallation( - logger: logger, - isWindows: false, - environment: { - 'HOME': tempDirectory.path, - }, - configuration: bashConfig, - )..install(rootCommand); - - final zshInstallation = - CompletionInstallation( - logger: logger, - isWindows: false, - environment: { - 'HOME': tempDirectory.path, - }, - configuration: zshConfig, - ) - ..install(rootCommand) - ..uninstall(rootCommand); - - // Zsh should be uninstalled - expect( - zshRCFile.existsSync(), - isTrue, - reason: 'Zsh RC file should still exist.', - ); - expect( - const ScriptConfigurationEntry('Completion').existsIn(zshRCFile), - isFalse, - reason: 'Zsh should not have completion entry.', - ); + final zshConfig = zshConfiguration; + final zshRCFile = File(path.join(tempDirectory.path, '.zshrc')) + ..createSync(); - final zshCompletionConfigurationFile = File( - path.join( - zshInstallation.completionConfigDir.path, - zshConfig.completionConfigForShellFileName, - ), - ); - expect( - zshCompletionConfigurationFile.existsSync(), - isFalse, - reason: 'Zsh completion configuration should be deleted.', - ); + final bashConfig = bashConfiguration; + final bashRCFile = File(path.join(tempDirectory.path, '.bash_profile')) + ..createSync(); - final zshCommandCompletionConfigurationFile = File( - path.join( - zshInstallation.completionConfigDir.path, - '$rootCommand.zsh', - ), - ); - expect( - zshCommandCompletionConfigurationFile.existsSync(), - isFalse, - reason: 'Zsh command completion configuration should be deleted.', - ); + const rootCommand = 'very_good'; - // Bash should still be installed - expect( - bashRCFile.existsSync(), - isTrue, - reason: 'Bash RC file should still exist.', - ); - expect( - const ScriptConfigurationEntry('Completion').existsIn(bashRCFile), - isTrue, - reason: 'Bash should have completion entry.', - ); + final bashInstallation = CompletionInstallation( + logger: logger, + isWindows: false, + environment: {'HOME': tempDirectory.path}, + configuration: bashConfig, + )..install(rootCommand); + + final zshInstallation = + CompletionInstallation( + logger: logger, + isWindows: false, + environment: {'HOME': tempDirectory.path}, + configuration: zshConfig, + ) + ..install(rootCommand) + ..uninstall(rootCommand); + + // Zsh should be uninstalled + expect( + zshRCFile.existsSync(), + isTrue, + reason: 'Zsh RC file should still exist.', + ); + expect( + const ScriptConfigurationEntry('Completion').existsIn(zshRCFile), + isFalse, + reason: 'Zsh should not have completion entry.', + ); - final bashCompletionConfigurationFile = File( - path.join( - bashInstallation.completionConfigDir.path, - bashConfig.completionConfigForShellFileName, - ), - ); - expect( - bashCompletionConfigurationFile.existsSync(), - isTrue, - reason: 'Bash completion configuration should still exist.', - ); + final zshCompletionConfigurationFile = File( + path.join( + zshInstallation.completionConfigDir.path, + zshConfig.completionConfigForShellFileName, + ), + ); + expect( + zshCompletionConfigurationFile.existsSync(), + isFalse, + reason: 'Zsh completion configuration should be deleted.', + ); - final bashCommandCompletionConfigurationFile = File( - path.join( - bashInstallation.completionConfigDir.path, - '$rootCommand.bash', - ), - ); - expect( - bashCommandCompletionConfigurationFile.existsSync(), - isTrue, - reason: 'Bash command completion configuration should still exist.', - ); + final zshCommandCompletionConfigurationFile = File( + path.join( + zshInstallation.completionConfigDir.path, + '$rootCommand.zsh', + ), + ); + expect( + zshCommandCompletionConfigurationFile.existsSync(), + isFalse, + reason: 'Zsh command completion configuration should be deleted.', + ); - expect( - bashInstallation.completionConfigDir.existsSync(), - isTrue, - reason: 'Completion configuration directory should still exist.', - ); - }, - ); + // Bash should still be installed + expect( + bashRCFile.existsSync(), + isTrue, + reason: 'Bash RC file should still exist.', + ); + expect( + const ScriptConfigurationEntry('Completion').existsIn(bashRCFile), + isTrue, + reason: 'Bash should have completion entry.', + ); - test( - '''only deletes command completion configuration when there are multiple installed commands''', - () { - final tempDirectory = Directory.systemTemp.createTempSync(); - addTearDown(() => tempDirectory.deleteSync(recursive: true)); + final bashCompletionConfigurationFile = File( + path.join( + bashInstallation.completionConfigDir.path, + bashConfig.completionConfigForShellFileName, + ), + ); + expect( + bashCompletionConfigurationFile.existsSync(), + isTrue, + reason: 'Bash completion configuration should still exist.', + ); - final configuration = zshConfiguration; - const commandName = 'very_good'; - const anotherCommandName = 'not_good'; + final bashCommandCompletionConfigurationFile = File( + path.join( + bashInstallation.completionConfigDir.path, + '$rootCommand.bash', + ), + ); + expect( + bashCommandCompletionConfigurationFile.existsSync(), + isTrue, + reason: 'Bash command completion configuration should still exist.', + ); - final rcFile = File(path.join(tempDirectory.path, '.zshrc')) - ..createSync(); - final installation = - CompletionInstallation( - logger: logger, - isWindows: false, - environment: { - 'HOME': tempDirectory.path, - }, - configuration: configuration, - ) - ..install(commandName) - ..install(anotherCommandName); + expect( + bashInstallation.completionConfigDir.existsSync(), + isTrue, + reason: 'Completion configuration directory should still exist.', + ); + }); - final shellCompletionConfigurationFile = File( - path.join( - installation.completionConfigDir.path, - configuration.completionConfigForShellFileName, - ), - ); + test('''only deletes command completion configuration when there are multiple installed commands''', () { + final tempDirectory = Directory.systemTemp.createTempSync(); + addTearDown(() => tempDirectory.deleteSync(recursive: true)); + + final configuration = zshConfiguration; + const commandName = 'very_good'; + const anotherCommandName = 'not_good'; + + final rcFile = File(path.join(tempDirectory.path, '.zshrc')) + ..createSync(); + final installation = + CompletionInstallation( + logger: logger, + isWindows: false, + environment: {'HOME': tempDirectory.path}, + configuration: configuration, + ) + ..install(commandName) + ..install(anotherCommandName); + + final shellCompletionConfigurationFile = File( + path.join( + installation.completionConfigDir.path, + configuration.completionConfigForShellFileName, + ), + ); - installation.uninstall(commandName); + installation.uninstall(commandName); - expect( - rcFile.existsSync(), - isTrue, - reason: 'RC file should not be deleted.', - ); - expect( - const ScriptConfigurationEntry('Completion').existsIn(rcFile), - isTrue, - reason: - 'Completion config entry should not be removed from RC file.', - ); + expect( + rcFile.existsSync(), + isTrue, + reason: 'RC file should not be deleted.', + ); + expect( + const ScriptConfigurationEntry('Completion').existsIn(rcFile), + isTrue, + reason: 'Completion config entry should not be removed from RC file.', + ); - expect( - shellCompletionConfigurationFile.existsSync(), - isTrue, - reason: 'Shell completion configuration should still exist.', - ); + expect( + shellCompletionConfigurationFile.existsSync(), + isTrue, + reason: 'Shell completion configuration should still exist.', + ); - expect( - const ScriptConfigurationEntry( - commandName, - ).existsIn(shellCompletionConfigurationFile), - isFalse, - reason: - '''Command completion for $commandName configuration should be removed.''', - ); - final commandCompletionConfigurationFile = File( - path.join( - installation.completionConfigDir.path, - '$commandName.zsh', - ), - ); - expect( - commandCompletionConfigurationFile.existsSync(), - false, - reason: - '''Command completion configuration for $commandName should be deleted.''', - ); + expect( + const ScriptConfigurationEntry(commandName) + .existsIn(shellCompletionConfigurationFile), + isFalse, + reason: + '''Command completion for $commandName configuration should be removed.''', + ); + final commandCompletionConfigurationFile = File( + path.join(installation.completionConfigDir.path, '$commandName.zsh'), + ); + expect( + commandCompletionConfigurationFile.existsSync(), + false, + reason: + '''Command completion configuration for $commandName should be deleted.''', + ); - expect( - const ScriptConfigurationEntry( - anotherCommandName, - ).existsIn(shellCompletionConfigurationFile), - isTrue, - reason: - '''Command completion configuration for $anotherCommandName should still exist.''', - ); - final anotherCommandCompletionConfigurationFile = File( - path.join( - installation.completionConfigDir.path, - '$anotherCommandName.zsh', - ), - ); - expect( - anotherCommandCompletionConfigurationFile.existsSync(), - isTrue, - reason: - '''Command completion configuration for $anotherCommandName should still exist.''', - ); - }, - ); + expect( + const ScriptConfigurationEntry(anotherCommandName) + .existsIn(shellCompletionConfigurationFile), + isTrue, + reason: + '''Command completion configuration for $anotherCommandName should still exist.''', + ); + final anotherCommandCompletionConfigurationFile = File( + path.join( + installation.completionConfigDir.path, + '$anotherCommandName.zsh', + ), + ); + expect( + anotherCommandCompletionConfigurationFile.existsSync(), + isTrue, + reason: + '''Command completion configuration for $anotherCommandName should still exist.''', + ); + }); test('adds command to uninstalls when not the last command', () { const systemShell = SystemShell.zsh; final installation = CompletionInstallation.fromSystemShell( systemShell: systemShell, logger: logger, - environmentOverride: { - 'HOME': tempDir.path, - }, + environmentOverride: {'HOME': tempDir.path}, ); File(path.join(tempDir.path, '.zshrc')).createSync(); @@ -1147,9 +1038,7 @@ void main() { final installation = CompletionInstallation.fromSystemShell( systemShell: systemShell, logger: logger, - environmentOverride: { - 'HOME': tempDir.path, - }, + environmentOverride: {'HOME': tempDir.path}, ); File(path.join(tempDir.path, '.zshrc')).createSync(); @@ -1180,9 +1069,7 @@ void main() { final installation = CompletionInstallation( logger: logger, isWindows: false, - environment: { - 'HOME': tempDir.path, - }, + environment: {'HOME': tempDir.path}, configuration: zshConfiguration, ); final rcFile = File(path.join(tempDir.path, '.zshrc')); @@ -1206,9 +1093,7 @@ void main() { final installation = CompletionInstallation( logger: logger, isWindows: false, - environment: { - 'HOME': tempDirectory.path, - }, + environment: {'HOME': tempDirectory.path}, configuration: zshConfiguration, ); @@ -1235,9 +1120,7 @@ void main() { final installation = CompletionInstallation( logger: logger, isWindows: false, - environment: { - 'HOME': tempDirectory.path, - }, + environment: {'HOME': tempDirectory.path}, configuration: configuration, ); diff --git a/test/src/installer/script_configuration_entry_test.dart b/test/src/installer/script_configuration_entry_test.dart index cc2bc2a..f7c50cd 100644 --- a/test/src/installer/script_configuration_entry_test.dart +++ b/test/src/installer/script_configuration_entry_test.dart @@ -27,10 +27,7 @@ void main() { final entry = ScriptConfigurationEntry('name'); - expect( - () => entry.appendTo(file), - returnsNormally, - ); + expect(() => entry.appendTo(file), returnsNormally); }); test('returns normally when file does not exist', () { @@ -42,10 +39,7 @@ void main() { final entry = ScriptConfigurationEntry('name'); - expect( - () => entry.appendTo(file), - returnsNormally, - ); + expect(() => entry.appendTo(file), returnsNormally); }); test('correctly appends content', () { @@ -188,61 +182,52 @@ $initialContent expect(content, equals(currentContent)); }); - test( - '''removes file when there is only a single matching entry and should delete''', - () { - final tempDirectory = Directory.systemTemp.createTempSync(); - addTearDown(() => tempDirectory.deleteSync(recursive: true)); + test('''removes file when there is only a single matching entry and should delete''', () { + final tempDirectory = Directory.systemTemp.createTempSync(); + addTearDown(() => tempDirectory.deleteSync(recursive: true)); - final filePath = path.join(tempDirectory.path, 'file'); - final file = File(filePath)..createSync(); + final filePath = path.join(tempDirectory.path, 'file'); + final file = File(filePath)..createSync(); - final entry = ScriptConfigurationEntry('name')..appendTo(file); - expect(entry.existsIn(file), isTrue); + final entry = ScriptConfigurationEntry('name')..appendTo(file); + expect(entry.existsIn(file), isTrue); - ScriptConfigurationEntry('name').removeFrom(file, shouldDelete: true); - expect(file.existsSync(), isFalse); - }, - ); + ScriptConfigurationEntry('name').removeFrom(file, shouldDelete: true); + expect(file.existsSync(), isFalse); + }); - test( - '''preseves file when there is a single matching entry and should not delete''', - () { - final tempDirectory = Directory.systemTemp.createTempSync(); - addTearDown(() => tempDirectory.deleteSync(recursive: true)); + test('''preseves file when there is a single matching entry and should not delete''', () { + final tempDirectory = Directory.systemTemp.createTempSync(); + addTearDown(() => tempDirectory.deleteSync(recursive: true)); - final filePath = path.join(tempDirectory.path, 'file'); - final file = File(filePath)..createSync(); + final filePath = path.join(tempDirectory.path, 'file'); + final file = File(filePath)..createSync(); - final entry = ScriptConfigurationEntry('name')..appendTo(file); - expect(entry.existsIn(file), isTrue); + final entry = ScriptConfigurationEntry('name')..appendTo(file); + expect(entry.existsIn(file), isTrue); - ScriptConfigurationEntry('name').removeFrom(file); - expect(file.existsSync(), isTrue); - final currentContent = file.readAsStringSync(); - expect(currentContent, isEmpty); - }, - ); + ScriptConfigurationEntry('name').removeFrom(file); + expect(file.existsSync(), isTrue); + final currentContent = file.readAsStringSync(); + expect(currentContent, isEmpty); + }); - test( - '''removes file when there are only multiple matching entries and should delete''', - () { - final tempDirectory = Directory.systemTemp.createTempSync(); - addTearDown(() => tempDirectory.deleteSync(recursive: true)); + test('''removes file when there are only multiple matching entries and should delete''', () { + final tempDirectory = Directory.systemTemp.createTempSync(); + addTearDown(() => tempDirectory.deleteSync(recursive: true)); - final filePath = path.join(tempDirectory.path, 'file'); - final file = File(filePath)..createSync(); + final filePath = path.join(tempDirectory.path, 'file'); + final file = File(filePath)..createSync(); - final entry = ScriptConfigurationEntry('name') - ..appendTo(file) - ..appendTo(file) - ..appendTo(file); - expect(entry.existsIn(file), isTrue); + final entry = ScriptConfigurationEntry('name') + ..appendTo(file) + ..appendTo(file) + ..appendTo(file); + expect(entry.existsIn(file), isTrue); - ScriptConfigurationEntry('name').removeFrom(file, shouldDelete: true); - expect(file.existsSync(), isFalse); - }, - ); + ScriptConfigurationEntry('name').removeFrom(file, shouldDelete: true); + expect(file.existsSync(), isFalse); + }); test('only removes matching entries from file', () { final tempDirectory = Directory.systemTemp.createTempSync(); diff --git a/test/src/parser/arg_parser_extension_test.dart b/test/src/parser/arg_parser_extension_test.dart index ee540e9..7dea1bd 100644 --- a/test/src/parser/arg_parser_extension_test.dart +++ b/test/src/parser/arg_parser_extension_test.dart @@ -47,12 +47,7 @@ void main() { results!; expect(results.name, null); - expect( - results.arguments, - [ - 'subcommand', - ], - ); + expect(results.arguments, ['subcommand']); expect( results.command, isA().having( @@ -81,11 +76,7 @@ void main() { }); group('findValidOptions', () { final argParser = ArgParser() - ..addFlag( - 'flag', - abbr: 'f', - aliases: ['flagalias'], - ) + ..addFlag('flag', abbr: 'f', aliases: ['flagalias']) ..addOption('mandatoryOption', mandatory: true) ..addMultiOption('multiOption', allowed: ['a', 'b', 'c']) ..addCommand('subcommand', ArgParser()); diff --git a/test/src/parser/completion_level_test.dart b/test/src/parser/completion_level_test.dart index 65af1b4..3a67476 100644 --- a/test/src/parser/completion_level_test.dart +++ b/test/src/parser/completion_level_test.dart @@ -5,7 +5,7 @@ import 'package:cli_completion/parser.dart'; import 'package:test/test.dart'; class _TestCompletionCommandRunner extends CompletionCommandRunner { - _TestCompletionCommandRunner() : super('test', 'Test command runner') { + new() : super('test', 'Test command runner') { argParser ..addOption('rootFlag') ..addCommand( @@ -28,10 +28,7 @@ class _TestCompletionCommandRunner extends CompletionCommandRunner { subCommand.addSubcommand(subSubCommand); subSubCommand.argParser ..addFlag('level2Flag') - ..addOption( - 'level2Option', - mandatory: true, - ); + ..addOption('level2Option', mandatory: true); final subSubSubCommand = _TestCommand( name: 'subsubsubcommand', @@ -42,10 +39,7 @@ class _TestCompletionCommandRunner extends CompletionCommandRunner { } class _TestCommand extends Command { - _TestCommand({ - required this.name, - required this.description, - }); + new({required this.name, required this.description}); @override final String description; @@ -57,75 +51,69 @@ class _TestCommand extends Command { void main() { group('CompletionLevel', () { group('find', () { - test( - 'gets completion level from the innermost aspet', - () { - final commanrRunner = _TestCompletionCommandRunner(); - final args = - '--rootFlag ' - 'subcommand --level1Flag ' - 'subsubcommand --level2Flag' - .split(' '); - - final completionLevel = CompletionLevel.find( - args, - commanrRunner.argParser, - commanrRunner.commands, - ); - - expect(completionLevel, isNotNull); - completionLevel!; - - expect(completionLevel.rawArgs, [ - '', - '--level2Flag', - ]); - - expect( - completionLevel.parsedOptions, - isA().having( - (results) => results.wasParsed('level2Flag'), - 'parsed level2Flag', - true, - ), - ); - - expect( - completionLevel.visibleOptions, - isA>() - .having( - (list) => list.length, - 'available options in the last level', - 2, - ) - .having( - (list) => list[0].name, - 'first option in the last level', - 'help', - ) - .having( - (list) => list[1].name, - 'second option in the last level', - 'level2Option', - ), - ); - - expect( - completionLevel.visibleSubcommands, - isA>>() - .having( - (list) => list.length, - 'available sub commands in the last level', - 1, - ) - .having( - (list) => list.single.name, - 'sub command in the last level', - 'subsubsubcommand', - ), - ); - }, - ); + test('gets completion level from the innermost aspet', () { + final commanrRunner = _TestCompletionCommandRunner(); + final args = + '--rootFlag ' + 'subcommand --level1Flag ' + 'subsubcommand --level2Flag' + .split(' '); + + final completionLevel = CompletionLevel.find( + args, + commanrRunner.argParser, + commanrRunner.commands, + ); + + expect(completionLevel, isNotNull); + completionLevel!; + + expect(completionLevel.rawArgs, ['', '--level2Flag']); + + expect( + completionLevel.parsedOptions, + isA().having( + (results) => results.wasParsed('level2Flag'), + 'parsed level2Flag', + true, + ), + ); + + expect( + completionLevel.visibleOptions, + isA>() + .having( + (list) => list.length, + 'available options in the last level', + 2, + ) + .having( + (list) => list[0].name, + 'first option in the last level', + 'help', + ) + .having( + (list) => list[1].name, + 'second option in the last level', + 'level2Option', + ), + ); + + expect( + completionLevel.visibleSubcommands, + isA>>() + .having( + (list) => list.length, + 'available sub commands in the last level', + 1, + ) + .having( + (list) => list.single.name, + 'sub command in the last level', + 'subsubsubcommand', + ), + ); + }); test( 'finds level when subcommand is added via "ArgParser.addCommand"', @@ -145,9 +133,7 @@ void main() { expect(completionLevel, isNotNull); completionLevel!; - expect(completionLevel.rawArgs, [ - '--fakeSubcommandFlag', - ]); + expect(completionLevel.rawArgs, ['--fakeSubcommandFlag']); }, ); }); diff --git a/test/src/parser/completion_result_test.dart b/test/src/parser/completion_result_test.dart index 7e0012d..9c2d124 100644 --- a/test/src/parser/completion_result_test.dart +++ b/test/src/parser/completion_result_test.dart @@ -4,11 +4,7 @@ import 'package:cli_completion/parser.dart'; import 'package:test/test.dart'; class _TestCommand extends Command { - _TestCommand({ - required this.name, - required this.description, - required this.aliases, - }); + new({required this.name, required this.description, required this.aliases}); @override final String description; @@ -22,53 +18,44 @@ class _TestCommand extends Command { void main() { group('AllOptionsAndCommandsCompletionResult', () { - test( - 'renders suggestions for all sub commands and options in' - ' a completion level', - () { - final testArgParser = ArgParser() - ..addOption('option1') - ..addFlag('option2', help: 'yay option 2') - ..addFlag( - 'trueflag', - negatable: false, - ); - - final completionLevel = CompletionLevel( - grammar: testArgParser, - rawArgs: const [], - visibleSubcommands: [ - _TestCommand( - name: 'command1', - description: 'yay command 1', - aliases: [], - ), - _TestCommand( - name: 'command2', - description: 'yay command 2', - aliases: ['alias'], - ), - ], - visibleOptions: testArgParser.options.values.toList(), - ); + test('renders suggestions for all sub commands and options in' + ' a completion level', () { + final testArgParser = ArgParser() + ..addOption('option1') + ..addFlag('option2', help: 'yay option 2') + ..addFlag('trueflag', negatable: false); + + final completionLevel = CompletionLevel( + grammar: testArgParser, + rawArgs: const [], + visibleSubcommands: [ + _TestCommand( + name: 'command1', + description: 'yay command 1', + aliases: [], + ), + _TestCommand( + name: 'command2', + description: 'yay command 2', + aliases: ['alias'], + ), + ], + visibleOptions: testArgParser.options.values.toList(), + ); - final completionResult = AllOptionsAndCommandsCompletionResult( - completionLevel: completionLevel, - ); + final completionResult = AllOptionsAndCommandsCompletionResult( + completionLevel: completionLevel, + ); - expect( - completionResult.completions, - { - 'command1': 'yay command 1', - 'command2': 'yay command 2', - '--option1': null, - '--option2': 'yay option 2', - '--no-option2': 'yay option 2', - '--trueflag': null, - }, - ); - }, - ); + expect(completionResult.completions, { + 'command1': 'yay command 1', + 'command2': 'yay command 2', + '--option1': null, + '--option2': 'yay option 2', + '--no-option2': 'yay option 2', + '--trueflag': null, + }); + }); }); group('AllAbbrOptionsCompletionResult', () { @@ -92,10 +79,7 @@ void main() { completionLevel: completionLevel, ); - expect( - completionResult.completions, - {'-a': null, '-b': 'yay flag1 2'}, - ); + expect(completionResult.completions, {'-a': null, '-b': 'yay flag1 2'}); }, ); }); @@ -134,100 +118,72 @@ void main() { pattern: 'co', ); - expect( - completionResult.completions, - { - 'command1': 'yay command 1', - 'command2': 'yay command 2', - 'command_not_weird': 'yay weird command', - }, - ); + expect(completionResult.completions, { + 'command1': 'yay command 1', + 'command2': 'yay command 2', + 'command_not_weird': 'yay weird command', + }); }, ); }); group('MatchingOptionsCompletionResult', () { - test( - 'renders suggestions only for options that starts with pattern', - () { - final testArgParser = ArgParser() - ..addOption('option1') - ..addOption( - 'noption2', - aliases: ['option2alias'], - help: 'yay noption2', - ) - ..addFlag('oflag1'); - - final completionLevel = CompletionLevel( - grammar: testArgParser, - rawArgs: const [], - visibleSubcommands: const [], - visibleOptions: testArgParser.options.values.toList(), - ); - - final completionResult = MatchingOptionsCompletionResult( - completionLevel: completionLevel, - pattern: 'o', - ); + test('renders suggestions only for options that starts with pattern', () { + final testArgParser = ArgParser() + ..addOption('option1') + ..addOption('noption2', aliases: ['option2alias'], help: 'yay noption2') + ..addFlag('oflag1'); + + final completionLevel = CompletionLevel( + grammar: testArgParser, + rawArgs: const [], + visibleSubcommands: const [], + visibleOptions: testArgParser.options.values.toList(), + ); - expect( - completionResult.completions, - { - '--option1': null, - '--option2alias': 'yay noption2', - '--oflag1': null, - }, - ); - }, - ); + final completionResult = MatchingOptionsCompletionResult( + completionLevel: completionLevel, + pattern: 'o', + ); - test( - 'renders suggestions only for negated flags', - () { - final testArgParser = ArgParser() - ..addOption('option1') - ..addOption( - 'noption2', - aliases: ['option2alias'], - help: 'yay noption2', - ) - ..addFlag('flag', aliases: ['aliasforflag']) - ..addFlag('trueflag', negatable: false); + expect(completionResult.completions, { + '--option1': null, + '--option2alias': 'yay noption2', + '--oflag1': null, + }); + }); - final completionLevel = CompletionLevel( - grammar: testArgParser, - rawArgs: const [], - visibleSubcommands: const [], - visibleOptions: testArgParser.options.values.toList(), - ); + test('renders suggestions only for negated flags', () { + final testArgParser = ArgParser() + ..addOption('option1') + ..addOption('noption2', aliases: ['option2alias'], help: 'yay noption2') + ..addFlag('flag', aliases: ['aliasforflag']) + ..addFlag('trueflag', negatable: false); + + final completionLevel = CompletionLevel( + grammar: testArgParser, + rawArgs: const [], + visibleSubcommands: const [], + visibleOptions: testArgParser.options.values.toList(), + ); - final completionResult = MatchingOptionsCompletionResult( - completionLevel: completionLevel, - pattern: 'no', - ); + final completionResult = MatchingOptionsCompletionResult( + completionLevel: completionLevel, + pattern: 'no', + ); - expect( - completionResult.completions, - { - '--noption2': 'yay noption2', - '--no-flag': null, - }, - ); + expect(completionResult.completions, { + '--noption2': 'yay noption2', + '--no-flag': null, + }); - final completionResultAlias = MatchingOptionsCompletionResult( - completionLevel: completionLevel, - pattern: 'no-a', - ); + final completionResultAlias = MatchingOptionsCompletionResult( + completionLevel: completionLevel, + pattern: 'no-a', + ); - expect( - completionResultAlias.completions, - { - '--no-aliasforflag': null, - }, - ); - }, - ); + expect(completionResultAlias.completions, {'--no-aliasforflag': null}); + }); }); group('OptionValuesCompletionResult', () { @@ -236,11 +192,7 @@ void main() { ..addOption( 'allowed', abbr: 'a', - allowed: [ - 'value', - 'valuesomething', - 'anothervalue', - ], + allowed: ['value', 'valuesomething', 'anothervalue'], allowedHelp: { 'valueyay': 'yay valueyay', 'valuesomething': 'yay valuesomething', diff --git a/test/src/parser/completion_state_test.dart b/test/src/parser/completion_state_test.dart index bf5270c..5710fd1 100644 --- a/test/src/parser/completion_state_test.dart +++ b/test/src/parser/completion_state_test.dart @@ -15,11 +15,7 @@ void main() { expect(state!.cword, 3); expect(state.point, 39); expect(state.line, 'example_cli some_command --discrete foo'); - expect(state.args, [ - 'some_command', - '--discrete', - 'foo', - ]); + expect(state.args, ['some_command', '--discrete', 'foo']); }); test('equality', () { @@ -49,26 +45,17 @@ void main() { final environment = { 'COMP_LINE': 'example_cli some_command --discrete foo', }; - expect( - CompletionState.fromEnvironment(environment), - isNull, - ); + expect(CompletionState.fromEnvironment(environment), isNull); }); test('returns null when only COMP_POINT is set', () { final environment = {'COMP_POINT': '12'}; - expect( - CompletionState.fromEnvironment(environment), - isNull, - ); + expect(CompletionState.fromEnvironment(environment), isNull); }); test('returns null when only COMP_CWORD is set', () { final environment = {'COMP_CWORD': '2'}; - expect( - CompletionState.fromEnvironment(environment), - isNull, - ); + expect(CompletionState.fromEnvironment(environment), isNull); }); test('returns null when COMP_CWORD or COMP_POINT are not ints', () { @@ -76,10 +63,7 @@ void main() { 'COMP_CWORD': 'sdasdas', 'COMP_POINT': 'asdasddd', }; - expect( - CompletionState.fromEnvironment(environment), - isNull, - ); + expect(CompletionState.fromEnvironment(environment), isNull); }); test('returns null when COMP_POINT is not at the end of the line', () { @@ -88,10 +72,7 @@ void main() { 'COMP_POINT': '0', 'COMP_CWORD': '0', }; - expect( - CompletionState.fromEnvironment(environment), - isNull, - ); + expect(CompletionState.fromEnvironment(environment), isNull); }); test('returns null when there an argument terminator', () { @@ -100,10 +81,7 @@ void main() { 'COMP_POINT': '42', 'COMP_CWORD': '4', }; - expect( - CompletionState.fromEnvironment(environment), - isNull, - ); + expect(CompletionState.fromEnvironment(environment), isNull); }); }); }); diff --git a/test/src/parser/parser_test.dart b/test/src/parser/parser_test.dart index c66907b..c70fc01 100644 --- a/test/src/parser/parser_test.dart +++ b/test/src/parser/parser_test.dart @@ -4,10 +4,7 @@ import 'package:cli_completion/parser.dart'; import 'package:test/test.dart'; class _TestCommand extends Command { - _TestCommand({ - required this.name, - required this.description, - }); + new({required this.name, required this.description}); @override final String description; @@ -57,10 +54,7 @@ void main() { final result = parser.parse(); expect(result.length, 1); - expect( - result.first, - isA(), - ); + expect(result.first, isA()); }); }); @@ -169,10 +163,7 @@ void main() { final result = parser.parse(); expect(result.length, 1); - expect( - result.first, - isA(), - ); + expect(result.first, isA()); }); }); @@ -206,12 +197,7 @@ void main() { final parser = CompletionParser( completionLevel: CompletionLevel( grammar: testArgParser, - rawArgs: const [ - '', - 'command1', - '--optionAllowed', - 'something', - ], + rawArgs: const ['', 'command1', '--optionAllowed', 'something'], visibleSubcommands: visibleSubcommands, visibleOptions: testArgParser.options.values.toList(), ), @@ -234,12 +220,7 @@ void main() { final parser = CompletionParser( completionLevel: CompletionLevel( grammar: testArgParser, - rawArgs: const [ - '', - 'command1', - '-a', - 'something', - ], + rawArgs: const ['', 'command1', '-a', 'something'], visibleSubcommands: visibleSubcommands, visibleOptions: testArgParser.options.values.toList(), ), diff --git a/test/src/system_shell_test.dart b/test/src/system_shell_test.dart index 5c6a97f..2e3901f 100644 --- a/test/src/system_shell_test.dart +++ b/test/src/system_shell_test.dart @@ -15,18 +15,13 @@ void main() { group('current', () { test('instantiated without env', () { - expect( - SystemShell.current, - returnsNormally, - ); + expect(SystemShell.current, returnsNormally); }); group('Heuristics', () { test('identifies zsh', () { final result = SystemShell.current( - environmentOverride: { - 'ZSH_NAME': 'zsh', - }, + environmentOverride: {'ZSH_NAME': 'zsh'}, ); expect(result, SystemShell.zsh); @@ -34,9 +29,7 @@ void main() { test('identifies bash', () { final result = SystemShell.current( - environmentOverride: { - 'BASH': '/bin/bash', - }, + environmentOverride: {'BASH': '/bin/bash'}, ); expect(result, SystemShell.bash); @@ -46,9 +39,7 @@ void main() { group(r'When checking $SHELL', () { test('identifies zsh', () { final result = SystemShell.current( - environmentOverride: { - 'SHELL': '/foo/bar/zsh', - }, + environmentOverride: {'SHELL': '/foo/bar/zsh'}, ); expect(result, SystemShell.zsh); @@ -56,17 +47,13 @@ void main() { test('identifies bash shell', () { final result = SystemShell.current( - environmentOverride: { - 'SHELL': '/foo/bar/bash', - }, + environmentOverride: {'SHELL': '/foo/bar/bash'}, ); expect(result, SystemShell.bash); final resultWindows = SystemShell.current( - environmentOverride: { - 'SHELL': r'c:\foo\bar\bash.exe', - }, + environmentOverride: {'SHELL': r'c:\foo\bar\bash.exe'}, ); expect(resultWindows, SystemShell.bash); @@ -74,18 +61,14 @@ void main() { group('identifies no shell', () { test('for no shell env', () { - final result = SystemShell.current( - environmentOverride: {}, - ); + final result = SystemShell.current(environmentOverride: {}); expect(result, null); }); test('for empty shell env', () { final result = SystemShell.current( - environmentOverride: { - 'SHELL': '', - }, + environmentOverride: {'SHELL': ''}, ); expect(result, null); @@ -93,9 +76,7 @@ void main() { test('for extraneous shell', () { final result = SystemShell.current( - environmentOverride: { - 'SHELL': '/usr/bin/someshell', - }, + environmentOverride: {'SHELL': '/usr/bin/someshell'}, ); expect(result, null); @@ -107,10 +88,7 @@ void main() { group('tryParse', () { group('returns bash', () { test('when given "bash"', () { - expect( - SystemShell.tryParse('bash'), - equals(SystemShell.bash), - ); + expect(SystemShell.tryParse('bash'), equals(SystemShell.bash)); }); test('when given "SystemShell.bash"', () { @@ -123,10 +101,7 @@ void main() { group('returns zsh', () { test('when given "zsh"', () { - expect( - SystemShell.tryParse('zsh'), - equals(SystemShell.zsh), - ); + expect(SystemShell.tryParse('zsh'), equals(SystemShell.zsh)); }); test('when given "SystemShell.zsh"', () {