-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Bumped sdk versions down to 3.0.0.
- Loading branch information
1 parent
8a0dacf
commit 5d88fea
Showing
9 changed files
with
131 additions
and
114 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<String>, | ||
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<String>, | ||
// 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<String> bar, { | ||
required String foo, | ||
int? baz = 42, | ||
Email email = const Email('default'), | ||
}) { | ||
throw UnimplementedError(); | ||
} | ||
// void userFunction( | ||
// List<String> 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<String, dynamic> json) => _$FooFromJson(json); | ||
} | ||
// factory Foo.fromJson(Map<String, dynamic> json) => _$FooFromJson(json); | ||
// } | ||
|
||
extension type const Bar(String val) { | ||
factory Bar.fromJson(Map<String, dynamic> json) { | ||
return Bar(json['val'] as String); | ||
} | ||
} | ||
// extension type const Bar(String val) { | ||
// factory Bar.fromJson(Map<String, dynamic> json) { | ||
// return Bar(json['val'] as String); | ||
// } | ||
// } |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ version: 1.0.0 | |
publish_to: none | ||
|
||
environment: | ||
sdk: ^3.2.0 | ||
sdk: ^3.0.0 | ||
|
||
dependencies: | ||
cli_annotations: | ||
|