Skip to content
pubscout

cli_config

0.2.0, released 3 years ago by tools.dart.dev

Library to read config from CLI args, env vars, and JSON/YAML files

Quiet but busy
$ flutter pub add cli_config
Source repository

What it does

It provides a uniform API to access configuration values from command‑line arguments, environment variables, and configuration files. The library handles precedence, hierarchical keys, and optional list merging.

AI-written summary of version 0.2.0, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You need a single source of truth for configuration across CLI, env, and files
  • You want hierarchical configuration with dot or double‑underscore separators
  • You need both sync and async configuration loading

Skip it when

  • You only need a single configuration source
  • You require code generation for config models

Strengths

  • Simple API with clear precedence rules
  • Supports hierarchical keys and list merging
  • Provides both async and sync loading

Weaknesses

  • No code generation or type safety for config models
  • Limited to CLI, env, and file sources only
  • No built‑in validation or schema support

Setup

Kind
Pure Dart
Effort
Low
Code generation
No
Direct dependencies
2
final config = await Config.fromArguments(arguments: arguments);
final pathValue = config.optionalPath('my_path', resolveUri: true, mustExist: false);
print(pathValue?.toFilePath());

Alternatives

Packages that do the same job and could replace cli_config.

Works with

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