args_macro 0.1.0-6.dev copy "args_macro: ^0.1.0-6.dev" to clipboard
args_macro: ^0.1.0-6.dev copied to clipboard

Generates a parser for command-line arguments based on your data class.

example/lib/main.dart

import 'package:args_macro/args_macro.dart';

@Args(
  description: 'The command description.',
  executableName: 'executable_name',
)
class MyArgs {
  final String requiredString;
  final String? optionalString;
  String stringWithDefault = 'My default string.';

  final int requiredInt;
  final int? optionalInt;
  int intWithDefault = 7;

  final double requiredDouble;
  final double? optionalDouble;
  double doubleWithDefault = 7.77;

  bool boolWithDefaultFalse = false;
  bool boolWithDefaultTrue = true;

  final Fruit requiredEnum;
  final Fruit? optionalEnum;
  Fruit enumWithDefault = Fruit.mango;
}

enum Fruit { apple, banana, mango, orange }

void main(List<String> argv) {
  final parser = MyArgsParser(); // Generated class.
  final MyArgs args = parser.parse(argv);

  stdout.write(args.toDebugString());
}
3
likes
0
pub points
17%
popularity

Publisher

verified publisherainkin.com

Generates a parser for command-line arguments based on your data class.

Repository (GitHub)
View/report issues

Topics

#cli #macros

License

unknown (license)

Dependencies

args, collection, common_macros, macro_util, macros

More

Packages that depend on args_macro