argv 1.0.1 copy "argv: ^1.0.1" to clipboard
argv: ^1.0.1 copied to clipboard

A sample arg parser for building CLI application followint the GNU and POSIX options style

Argv #

A lightweight, production-ready command-line argument parser for Dart.

Features #

  • Flags & Options - Boolean flags and value options with validation
  • Commands - Nested command structures (git-like CLIs)
  • Validation - Required arguments, allowed values, typo suggestions
  • Simple API - Fluent, chainable interface

Quick Start #

import 'package:argv/argv.dart';

void main(List<String> args) {
  final parser = Argv('myapp')
    .flag('verbose', abbr: 'v', description: 'Verbose output')
    .option('output', abbr: 'o', defaultValue: 'result.txt')
    .positional('input');

  final result = parser.run(args);
  
  if (result.flag('verbose')) {
    print('Processing ${result.positional('input')}...');
  }
}

Commands #

final git = Argv('git');

git.command('commit')
  .option('message', abbr: 'm', required: true)
  .flag('all', abbr: 'a')
  .on((result) {
    print('Committing: ${result.option('message')}');
  });

git.run(['commit', '-m', 'Initial commit', '--all']);

Installation #

dependencies:
  argv: ^1.0.0

Usage Examples #

# Basic usage
myapp --verbose --output result.txt input.txt

# Commands with options  
git commit -m "Fix bug" --all
docker run -d --name myapp nginx:latest

# Validation with suggestions
myapp --verbos  # Error: Unknown argument --verbos. Did you mean --verbose?
1
likes
0
points
12
downloads

Publisher

verified publishermarcomit.it

Weekly Downloads

A sample arg parser for building CLI application followint the GNU and POSIX options style

Repository (GitHub)
View/report issues

License

unknown (license)

More

Packages that depend on argv