Skip to content
pubscout

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.

WASM-readyQuiet but busy
$ flutter pub add args
Source repository

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')); // debug

Alternatives

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.

  • bosun

    Library for parsing CLI input and structuring commands

  • dart_pdf_reader

    Pure‑dart PDF parser that reads PDF structures from a byte stream.

  • csslib

    A Dart library that parses CSS strings or byte lists into an AST.

Works with

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