Pub Version Dart SDK Version Pub popularity

cli_info_builder

A package that provides a builder to generate a class to pack information about a Dart CLI application.

Usage

  1. Add the necessary dependencies:

    dart pub add cli_info
    dart pub add dev:build_runner
    dart pub add dev:cli_info_builder
    
  2. Run a build:

    dart pub run build_runner build
    
  3. lib/gen/cli_info.dart will be generated with content:

    // coverage:ignore-file
    // GENERATED CODE - DO NOT MODIFY BY HAND
    // ignore_for_file: type=lint
    // ignore_for_file: lines_longer_than_80_chars
    
    import 'package:cli_info/cli_info.dart';
    
    const cliInfo = CliInfo(
        //...
    );
    

Optional

To change the index of the target executable name or the path of the generated file, create a build.yaml in the root of the package and write the following:

targets:
  $default:
    builders:
      cli_info_builder:
        options:
          executables-index: 1 # default is 0
          output: "lib/gen/info.dart" # default is "lib/gen/cli_info.dart"

See also

Libraries

cli_info_builder