args
2.7.0, released 2 years ago by dart.dev
Library for parsing raw command-line arguments into options and values using GNU and POSIX styles.
What it does
Parses raw command-line arguments into typed options, flags, and multi-options following GNU and POSIX standards. It also supports structuring command-line applications with commands, subcommands, and automated help text generation via a CommandRunner class.
AI-written summary of version 2.7.0, based on the package's README and metadata. Report an inaccuracy
Use it when
- You are building a command-line interface (CLI) application in Dart.
- You need to parse flags, options, and multi-options with default values and validation.
- You want to structure a CLI app with nested commands and automatic help generation.
Skip it when
- You are building a purely graphical or web user interface without command-line input.
- You require complex positional grammar that cannot be modeled by standard GNU/POSIX flags and commands.
Strengths
- Supports both GNU and POSIX style options and flags.
- Built-in Command and CommandRunner classes for structured CLI apps with automatic help menus.
- Robust validation including allowed values and mandatory options.
Weaknesses
- Imperative approach requires manually setting up parsers and commands in code.
Setup
- Kind
- Pure Dart
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 0
var parser = ArgParser();
parser.addOption('mode');
parser.addFlag('verbose', defaultsTo: true);
var results = parser.parse(['--mode', 'debug', 'something', 'else']);
print(results.option('mode')); // debugAlternatives
Packages that do the same job and could replace args.
- cli_util
Utilities to help build Dart command-line apps, find the SDK, and display progress.
88Compare - bosun
Library for parsing CLI input and structuring commands
40Compare - dart_pdf_reader
Pure‑dart PDF parser that reads PDF structures from a byte stream.
62Compare - csslib
A Dart library that parses CSS strings or byte lists into an AST.
50Compare
Works with
Packages commonly used together with args: ones it builds on, ones built on it, and its own family.
- xmlBuilt on argsFull-featured XML and XPath library for DOM parsing, SAX streaming, and fluent building.
- dart_styleBuilt on argsProvides an API and CLI to format Dart source code automatically.
- coverageBuilt on argsCollects, manipulates, and formats code coverage data in Dart
- cli_configBuilt on argsLibrary to read config from CLI args, env vars, and JSON/YAML files
- jniBuilt on argsProvides Dart/Flutter bindings to call native Java code via JNI.
- devtools_sharedBuilt on argsShared Dart structures and server classes between devtools_app and other tools.
- completionBuilt on argsAdds shell command completion support to Dart console apps.
- native_stack_tracesBuilt on argsDecode non-symbolic stack traces from AOT-compiled Dart apps using stored debugging info