Coder Social home page Coder Social logo

kevmoo / build_cli Goto Github PK

View Code? Open in Web Editor NEW
51.0 51.0 12.0 378 KB

A builder that generates an ArgsParser from a class

Home Page: https://pub.dev/packages/build_cli

License: MIT License

Dart 95.27% Shell 4.73%
code-generation command-line-parser dart dart-build-system

build_cli's People

Contributors

dependabot[bot] avatar fzyzcjy avatar johnpryan avatar kevmoo avatar skycoder42 avatar zolotyh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

build_cli's Issues

Support `List<int>` type

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;
   │                  ^^^^^^^
   ╵

Add support for optional integer options

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,

[Feature request] Upgrade `source_gen` to version 0.9.0

  • Dart SDK : 2.0.0-dev.69.2 (Mon Jul 23 17:10:56 2018 +0200) on "windows_x64"
  • build_cli : 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.

Can't set null on boolean field

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.