From 5d88fea96a85b05dbe5363fb6d5c25442d73489c Mon Sep 17 00:00:00 2001 From: pattobrien <12474318+pattobrien@users.noreply.github.com> Date: Tue, 13 Feb 2024 07:29:06 -0500 Subject: [PATCH] chore: Bumped sdk versions down to 3.0.0. --- example/pubspec.yaml | 2 +- lib/runner.dart | 180 +++++++++--------- lib/runner.g.dart | 30 +-- pubspec.lock | 2 +- pubspec.yaml | 2 +- src/cli_annotations/pubspec.yaml | 11 +- .../code/models/command_parameter_model.dart | 5 +- src/cli_gen/pubspec.yaml | 11 +- src/cli_gen/test/example_project/pubspec.yaml | 2 +- 9 files changed, 131 insertions(+), 114 deletions(-) diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 76a3580..ef5402e 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -4,7 +4,7 @@ version: 1.0.0 publish_to: none environment: - sdk: ^3.2.0 + sdk: ^3.0.0 dependencies: args: ^2.4.2 diff --git a/lib/runner.dart b/lib/runner.dart index d3b6c1b..7b2df66 100644 --- a/lib/runner.dart +++ b/lib/runner.dart @@ -1,105 +1,105 @@ -import 'package:args/args.dart'; -import 'package:args/command_runner.dart'; -import 'package:json_annotation/json_annotation.dart'; +// import 'package:args/args.dart'; +// import 'package:args/command_runner.dart'; +// import 'package:json_annotation/json_annotation.dart'; -part 'runner.g.dart'; +// part 'runner.g.dart'; -void main() async { - final runner = ExampleRunner(); - final args = ['example', '--foo', 'bar']; // explicit option supplied - await runner.run(args); +// void main() async { +// final runner = ExampleRunner(); +// final args = ['example', '--foo', 'bar']; // explicit option supplied +// await runner.run(args); - final args2 = ['example']; // no explicit option supplied - await runner.run(args2); -} +// final args2 = ['example']; // no explicit option supplied +// await runner.run(args2); +// } -class ExampleRunner extends CommandRunner { - ExampleRunner() : super('example', 'Example command runner.') { - addCommand(ExampleCommand()); - } -} +// class ExampleRunner extends CommandRunner { +// ExampleRunner() : super('example', 'Example command runner.') { +// addCommand(ExampleCommand()); +// } +// } -class ExampleCommand extends Command { - @override - String get description => 'Example command description.'; +// class ExampleCommand extends Command { +// @override +// String get description => 'Example command description.'; - @override - String get name => 'example'; +// @override +// String get name => 'example'; - @override - ArgParser get argParser => ArgParser() - ..addOption( - 'foo', - abbr: 'f', - mandatory: false, - defaultsTo: 'default', - ) - ..addMultiOption( - 'bar', - abbr: 'b', - splitCommas: true, - ) - ..addFlag( - 'bar', - abbr: 'b', - negatable: false, - ); +// @override +// ArgParser get argParser => ArgParser() +// ..addOption( +// 'foo', +// abbr: 'f', +// mandatory: false, +// defaultsTo: 'default', +// ) +// ..addMultiOption( +// 'bar', +// abbr: 'b', +// splitCommas: true, +// ) +// ..addFlag( +// 'bar', +// abbr: 'b', +// negatable: false, +// ); - @override - run() { - final results = argResults!; +// @override +// run() { +// final results = argResults!; - userFunction( - results['bar'] as List, - foo: results['foo'] as String, - baz: results['baz'] != null ? int.parse(results['baz']) : null, - email: results.wasParsed( - 'email') // conditional to check if option was supplied (only necessary for `canBeNull` parameters) - ? Email.parse(results['email']) // the `parse` method - : const Email('default'), // copied from `defaultValueCode` - ); - } -} +// userFunction( +// results['bar'] as List, +// foo: results['foo'] as String, +// baz: results['baz'] != null ? int.parse(results['baz']) : null, +// email: results.wasParsed( +// 'email') // conditional to check if option was supplied (only necessary for `canBeNull` parameters) +// ? Email.parse(results['email']) // the `parse` method +// : const Email('default'), // copied from `defaultValueCode` +// ); +// } +// } -void userFunction( - List bar, { - required String foo, - int? baz = 42, - Email email = const Email('default'), -}) { - throw UnimplementedError(); -} +// void userFunction( +// List bar, { +// required String foo, +// int? baz = 42, +// Email email = const Email('default'), +// }) { +// throw UnimplementedError(); +// } -extension type const Email(String value) { - factory Email.parse(String value) { - // check if value is valid - final regexp = RegExp(r'^\S+@\S+\.\S+$'); - if (!regexp.hasMatch(value)) { - throw ArgumentError('Invalid email address'); - } - return Email(value); - } -} +// extension type const Email(String value) { +// factory Email.parse(String value) { +// // check if value is valid +// final regexp = RegExp(r'^\S+@\S+\.\S+$'); +// if (!regexp.hasMatch(value)) { +// throw ArgumentError('Invalid email address'); +// } +// return Email(value); +// } +// } -@JsonSerializable() -class Foo { - final String stringValue; - final bool boolValue; - final int intValue; - final Bar bar; +// @JsonSerializable() +// class Foo { +// final String stringValue; +// final bool boolValue; +// final int intValue; +// final Bar bar; - const Foo({ - this.stringValue = 'default', - this.boolValue = true, - this.intValue = 42, - this.bar = const Bar('default'), - }); +// const Foo({ +// this.stringValue = 'default', +// this.boolValue = true, +// this.intValue = 42, +// this.bar = const Bar('default'), +// }); - factory Foo.fromJson(Map json) => _$FooFromJson(json); -} +// factory Foo.fromJson(Map json) => _$FooFromJson(json); +// } -extension type const Bar(String val) { - factory Bar.fromJson(Map json) { - return Bar(json['val'] as String); - } -} +// extension type const Bar(String val) { +// factory Bar.fromJson(Map json) { +// return Bar(json['val'] as String); +// } +// } diff --git a/lib/runner.g.dart b/lib/runner.g.dart index 7813e50..1f9873d 100644 --- a/lib/runner.g.dart +++ b/lib/runner.g.dart @@ -1,19 +1,19 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND +// // GENERATED CODE - DO NOT MODIFY BY HAND -part of 'runner.dart'; +// part of 'runner.dart'; -// ************************************************************************** -// JsonSerializableGenerator -// ************************************************************************** +// // ************************************************************************** +// // JsonSerializableGenerator +// // ************************************************************************** -Foo _$FooFromJson(Map json) => Foo( - stringValue: json['stringValue'] as String? ?? 'default', - boolValue: json['boolValue'] as bool? ?? true, - intValue: json['intValue'] as int? ?? 42, - ); +// Foo _$FooFromJson(Map json) => Foo( +// stringValue: json['stringValue'] as String? ?? 'default', +// boolValue: json['boolValue'] as bool? ?? true, +// intValue: json['intValue'] as int? ?? 42, +// ); -Map _$FooToJson(Foo instance) => { - 'stringValue': instance.stringValue, - 'boolValue': instance.boolValue, - 'intValue': instance.intValue, - }; +// Map _$FooToJson(Foo instance) => { +// 'stringValue': instance.stringValue, +// 'boolValue': instance.boolValue, +// 'intValue': instance.intValue, +// }; diff --git a/pubspec.lock b/pubspec.lock index f2a8d7c..12e8a79 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -538,4 +538,4 @@ packages: source: hosted version: "3.1.2" sdks: - dart: ">=3.3.0 <4.0.0" + dart: ">=3.2.0 <4.0.0" diff --git a/pubspec.yaml b/pubspec.yaml index 130dd40..0383283 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -2,7 +2,7 @@ name: cli_gen description: The workspace for the cli_gen package. environment: - sdk: ^3.3.0 + sdk: ^3.0.0 dependencies: analyzer: ^6.4.1 diff --git a/src/cli_annotations/pubspec.yaml b/src/cli_annotations/pubspec.yaml index db5afe3..5742a9a 100644 --- a/src/cli_annotations/pubspec.yaml +++ b/src/cli_annotations/pubspec.yaml @@ -1,9 +1,18 @@ name: cli_annotations description: A sample command-line application. version: 0.1.0-dev.1 +homepage: https://github.com/pattobrien/cli-gen +repository: https://github.com/pattobrien/cli-gen +issue_tracker: https://github.com/pattobrien/cli-gen/issues + +topics: + - cli + - args + - codegen + - macros environment: - sdk: ^3.2.0 + sdk: ^3.0.0 dependencies: args: ^2.4.2 diff --git a/src/cli_gen/lib/src/code/models/command_parameter_model.dart b/src/cli_gen/lib/src/code/models/command_parameter_model.dart index a5fb16f..9eda68c 100644 --- a/src/cli_gen/lib/src/code/models/command_parameter_model.dart +++ b/src/cli_gen/lib/src/code/models/command_parameter_model.dart @@ -33,10 +33,9 @@ class CommandParameterModel { Expression? get computedDefaultValue { return annotations.map((e) => e.defaultsTo).firstOrNull ?? (_computedDefaultValue != null - // ? CodeExpression(Code("'$_computedDefaultValue'")) ? type.symbol == 'bool' - ? literalBool(bool.parse(_computedDefaultValue)) - : literalString(_computedDefaultValue) + ? literalBool(bool.parse(_computedDefaultValue!)) + : literalString(_computedDefaultValue!) : null); } diff --git a/src/cli_gen/pubspec.yaml b/src/cli_gen/pubspec.yaml index b4d0ab3..d23ce39 100644 --- a/src/cli_gen/pubspec.yaml +++ b/src/cli_gen/pubspec.yaml @@ -2,9 +2,18 @@ name: cli_gen description: A sample command-line application. version: 0.1.0-dev.1 publish_to: none +homepage: https://github.com/pattobrien/cli-gen +repository: https://github.com/pattobrien/cli-gen +issue_tracker: https://github.com/pattobrien/cli-gen/issues + +topics: + - cli + - args + - codegen + - macros environment: - sdk: ^3.2.0 + sdk: ^3.0.0 dependencies: analyzer: ^6.4.1 diff --git a/src/cli_gen/test/example_project/pubspec.yaml b/src/cli_gen/test/example_project/pubspec.yaml index 6b40a05..ec8d9a1 100644 --- a/src/cli_gen/test/example_project/pubspec.yaml +++ b/src/cli_gen/test/example_project/pubspec.yaml @@ -4,7 +4,7 @@ version: 1.0.0 publish_to: none environment: - sdk: ^3.2.0 + sdk: ^3.0.0 dependencies: cli_annotations: