build_cli
2.3.2, released 5 weeks ago by kevmoo.com
Parse command line arguments directly into an annotation class using build_runner or a standalone CLI.
What it does
Parse command line arguments by annotating classes with @CliOptions() and fields with @CliOption(). It generates helper code to populate your options class from command line arguments.
AI-written summary of version 2.3.2, based on the package's README and metadata. Report an inaccuracy
Use it when
- You need to parse command-line arguments in Dart CLI applications or packages.
- You prefer an annotation-driven approach to configuring options and flags.
Skip it when
- You prefer parsing command line arguments manually using the args package directly without code generation.
Strengths
- Supports running as a standalone CLI or with build_runner.
- Uses package:args under the hood.
- Handles custom types like enums and generated helpers automatically.
Weaknesses
- Requires code generation steps in your workflow.
Setup
- Kind
- Pure Dart
- Effort
- Low
- Code generation
- Yes (build_runner)
- Direct dependencies
- 12
Add build_cli_annotations to dependencies and either run the standalone CLI (`dart run build_cli@`) or add build_cli and build_runner to dev_dependencies.
import 'package:build_cli_annotations/build_cli_annotations.dart';
part 'example.g.dart';
@CliOptions()
class Options {
@CliOption(abbr: 'n', help: 'Required. The name to use in the greeting.')
final String name;
final bool nameWasParsed;
Options(this.name, {this.nameWasParsed = false});
}Alternatives
Packages that do the same job and could replace build_cli.
- copy_with_extension
Annotation for generating copyWith extensions code using copy_with_extension_gen.
87Compare - widgetbook_annotation
Annotations for widgetbook_generator to build Flutter widgets in isolation.
80Compare - dart_mappable
JSON serialization and data classes generator supporting generics, inheritance, and customization.
89Compare - shelf_router_generator
Generate request routers for the shelf web-framework using source annotations.
77Compare
Works with
Packages commonly used together with build_cli: ones it builds on, ones built on it, and its own family.
- analyzerbuild_cli depends on itPerforms static analysis of Dart code for tool integration and embedding.
- yamlbuild_cli depends on itA Dart library for parsing YAML documents into Dart data structures.
- pub_semverbuild_cli depends on itVersions and version constraints implementing pub's versioning policy.
- dart_stylebuild_cli depends on itProvides an API and CLI to format Dart source code automatically.
- argsbuild_cli depends on itLibrary for parsing raw command-line arguments into options and values using GNU and POSIX styles.
- cli_utilbuild_cli depends on itUtilities to help build Dart command-line apps, find the SDK, and display progress.
- buildbuild_cli depends on itPackage for authoring build_runner compatible code generators.
- build_configbuild_cli depends on itFormat definition and support for parsing build.yaml configuration.