kevmoo / build_cli Goto Github PK
View Code? Open in Web Editor NEWA builder that generates an ArgsParser from a class
Home Page: https://pub.dev/packages/build_cli
License: MIT License
A builder that generates an ArgsParser from a class
Home Page: https://pub.dev/packages/build_cli
License: MIT License
Currently it errors:
Could not handle field `userIds`. Lists of type `int` are not supported.
package:dart_admin/commands/client_updater.dart:22:18
╷
22 │ late List<int> userIds;
│ ^^^^^^^
╵
is there a way with build_cli to use addCommand ? if yes how ?
thanks
I have an option defined like this:
@CliOption()
final int? maxKeep;
Which generates the following parser code:
maxKeep: int.tryParse(result['max-keep'] as String) ??
_$badNumberFormat(
result['max-keep'] as String,
'int',
'max-keep',
),
This code has a problem. As I do not define a default value for the CLI option, result['max-keep']
actually returns null
, which cannot be cast to a string and thus throws an exception:
Unhandled exception:
type 'Null' is not a subtype of type 'String' in type cast
#0 _$parseOptionsResult (package:podman_backup/src/cli/options.g.dart:45:48)
#1 Options.parseOptions (package:podman_backup/src/cli/options.dart:203:7)
Please fix this problem by adding a null check. Something like the following could work:
maxKeep: result['max-keep'] != null
? int.tryParse(result['max-keep'] as String) ??
_$badNumberFormat(
result['max-keep'] as String,
'int',
'max-keep',
)
: null,
Would like to use build_cli
together with analyzer
^6.0.0
2.0.0-dev.69.2 (Mon Jul 23 17:10:56 2018 +0200) on "windows_x64"
0.2.4+1
I'm using packages json_annotation
v1.0.0 and json_serializable
v1.0.0 to add JSON support to some model classes to a project providing an executable that uses build_cli
.
These packages rely on source_gen
v0.9.0 but build_cli
rely on v0.8.2. So I can't install the project dependencies :
$ pub get
Resolving dependencies...
Because build_cli >=0.2.4 depends on source_gen ^0.8.2 and json_serializable >=1.0.0 depends on source_gen ^0.9.0, build_cli >=0.2.4 is incompatible with json_serializable >=1.0.0.
So, because my_app depends on both json_serializable ^1.0.0 and build_cli ^0.2.4, version solving failed.
Now, build_cli can't generate code which matched this:
// file.dart
import 'package:args/args.dart';
void main(Iterable<String> args) {
final parser = new ArgParser()..addFlag('test', defaultsTo: null, negatable: true);
final results = parser.parse(args);
print(results['test']);
}
dart file.dart
// null
In my case, I don't want to have a true or false value. I want to have null. But I can't have it.
Warn during generation?
Improve error when parsing?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.