Skip to content
pubscout

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.

$ flutter pub add build_cli
Source repository

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.

Works with

Packages commonly used together with build_cli: ones it builds on, ones built on it, and its own family.