From b2ea72914a8849ca8e5b2c70321d55e62d5f662c Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Wed, 17 Apr 2024 14:35:51 -0700 Subject: [PATCH 1/2] Update to latest lints, require Dart 3.3 Also enable CI on main branch --- .github/workflows/test-package.yml | 8 +++----- CHANGELOG.md | 4 ++++ analysis_options.yaml | 4 ---- lib/src/arg_parser.dart | 8 ++++---- lib/src/usage.dart | 2 +- pubspec.yaml | 6 +++--- test/allow_anything_test.dart | 3 ++- test/command_test.dart | 7 ++++--- test/parse_test.dart | 2 +- test/test_utils.dart | 2 +- 10 files changed, 23 insertions(+), 23 deletions(-) diff --git a/.github/workflows/test-package.yml b/.github/workflows/test-package.yml index c588233..0a6d9cb 100644 --- a/.github/workflows/test-package.yml +++ b/.github/workflows/test-package.yml @@ -3,9 +3,9 @@ name: Dart CI on: # Run CI on pushes to the main branch, and on PRs against main. push: - branches: [ master ] + branches: [ main ] pull_request: - branches: [ master ] + branches: [ main ] schedule: - cron: "0 0 * * 0" env: @@ -44,10 +44,8 @@ jobs: strategy: fail-fast: false matrix: - # Add macos-latest and/or windows-latest if relevant for this package os: [ubuntu-latest] - # Add stable if the package should also be tested on stable - sdk: ['3.0', dev] + sdk: ['3.3', dev] steps: - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 - uses: dart-lang/setup-dart@f0ead981b4d9a35b37f30d36160575d60931ec30 diff --git a/CHANGELOG.md b/CHANGELOG.md index cbf7efc..8e572ec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 2.5.1-wip + +* Require Dart 3.3 + ## 2.5.0 * Introduce new typed `ArgResults` `flag(String)`, `option(String)`, and diff --git a/analysis_options.yaml b/analysis_options.yaml index 424f0d3..a96c5ee 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -6,13 +6,9 @@ linter: rules: - avoid_unused_constructor_parameters - cancel_subscriptions - - comment_references - literal_only_boolean_expressions - missing_whitespace_between_adjacent_strings - no_adjacent_strings_in_list - no_runtimeType_toString - package_api_docs - - prefer_relative_imports - - test_types_in_equals - unnecessary_await_in_return - - use_super_parameters diff --git a/lib/src/arg_parser.dart b/lib/src/arg_parser.dart index ef91b80..c47c003 100644 --- a/lib/src/arg_parser.dart +++ b/lib/src/arg_parser.dart @@ -27,7 +27,7 @@ class ArgParser { /// A list of the [Option]s in [options] intermingled with [String] /// separators. - final _optionsAndSeparators = []; + final _optionsAndSeparators = []; /// Whether or not this parser parses options that appear after non-option /// arguments. @@ -142,7 +142,7 @@ class ArgParser { null, null, defaultsTo, - callback == null ? null : (value) => callback(value as bool), + callback == null ? null : (bool value) => callback(value), OptionType.flag, negatable: negatable, hide: hide, @@ -264,7 +264,7 @@ class ArgParser { allowed, allowedHelp, defaultsTo?.toList() ?? [], - callback == null ? null : (value) => callback(value as List), + callback == null ? null : (List value) => callback(value), OptionType.multiple, splitCommas: splitCommas, hide: hide, @@ -278,7 +278,7 @@ class ArgParser { String? valueHelp, Iterable? allowed, Map? allowedHelp, - defaultsTo, + Object? defaultsTo, Function? callback, OptionType type, {bool negatable = false, diff --git a/lib/src/usage.dart b/lib/src/usage.dart index d97cc2d..1ef9627 100644 --- a/lib/src/usage.dart +++ b/lib/src/usage.dart @@ -236,7 +236,7 @@ class _Usage { String _buildAllowedList(Option option) { var isDefault = option.defaultsTo is List ? (option.defaultsTo as List).contains - : (value) => value == option.defaultsTo; + : (String value) => value == option.defaultsTo; var allowedBuffer = StringBuffer(); allowedBuffer.write('['); diff --git a/pubspec.yaml b/pubspec.yaml index 40967a6..df4a847 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: args -version: 2.5.0 +version: 2.5.1-wip description: >- Library for defining parsers for parsing raw command-line arguments into a set of options and values using GNU and POSIX style options. @@ -9,8 +9,8 @@ topics: - cli environment: - sdk: ^3.0.0 + sdk: ^3.3.0 dev_dependencies: - dart_flutter_team_lints: ^1.0.0 + dart_flutter_team_lints: ^2.0.0 test: ^1.16.0 diff --git a/test/allow_anything_test.dart b/test/allow_anything_test.dart index 40bb95b..52e22b7 100644 --- a/test/allow_anything_test.dart +++ b/test/allow_anything_test.dart @@ -56,7 +56,8 @@ void main() { }); test('works as a subcommand in a CommandRunner', () async { - var commandRunner = CommandRunner('command', 'Description of command'); + var commandRunner = + CommandRunner('command', 'Description of command'); var command = AllowAnythingCommand(); commandRunner.addCommand(command); diff --git a/test/command_test.dart b/test/command_test.dart index bae9136..555cc8d 100644 --- a/test/command_test.dart +++ b/test/command_test.dart @@ -4,6 +4,7 @@ import 'package:args/command_runner.dart'; import 'package:test/test.dart'; + import 'test_utils.dart'; void main() { @@ -12,7 +13,7 @@ void main() { foo = FooCommand(); // Make sure [Command.runner] is set up. - CommandRunner('test', 'A test command runner.').addCommand(foo); + CommandRunner('test', 'A test command runner.').addCommand(foo); }); group('.invocation has a sane default', () { @@ -92,7 +93,7 @@ Run "test help" to see global options.''')); var wrapping = WrappingCommand(); // Make sure [Command.runner] is set up. - CommandRunner('longtest', 'A long-lined test command runner.') + CommandRunner('longtest', 'A long-lined test command runner.') .addCommand(wrapping); wrapping.addSubcommand(LongCommand()); @@ -118,7 +119,7 @@ options.''')); var longCommand = LongCommand(); // Make sure [Command.runner] is set up. - CommandRunner('longtest', 'A long-lined test command runner.') + CommandRunner('longtest', 'A long-lined test command runner.') .addCommand(longCommand); expect(longCommand.usage, equals(''' diff --git a/test/parse_test.dart b/test/parse_test.dart index 9276fc4..b2dda44 100644 --- a/test/parse_test.dart +++ b/test/parse_test.dart @@ -260,7 +260,7 @@ void main() { // This reified type is important in strong mode so that people can // safely write "as List". - expect(a, TypeMatcher>()); + expect(a, isA>()); }); test( diff --git a/test/test_utils.dart b/test/test_utils.dart index 5cfb74a..f19da6d 100644 --- a/test/test_utils.dart +++ b/test/test_utils.dart @@ -308,7 +308,7 @@ class AsyncCommand extends Command { final takesArguments = false; @override - Future run() => Future.value().then((_) => hasRun = true); + Future run() => Future.value().then((_) => hasRun = true); } class AllowAnythingCommand extends Command { From 61c905025153f6e1cd3557a5fd5a814d32633ef4 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Wed, 17 Apr 2024 14:45:03 -0700 Subject: [PATCH 2/2] more more main --- .github/workflows/publish.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index fcb7ccb..f416320 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -4,7 +4,7 @@ name: Publish on: pull_request: - branches: [ master ] + branches: [ main ] push: tags: [ 'v[0-9]+.[0-9]+.[0-9]+*' ]