Argv class
This class is the main core of argv library.
It is the parser of arguments and the builder for command-line interfaces. Use this class to define your CLI structure with commands, flags, options, and positional arguments.
Example:
final parser = Argv('myapp', 'My awesome CLI application')
.flag('verbose', abbr: 'v', description: 'Verbose output')
.option('output', abbr: 'o', defaultValue: 'result.txt')
.positional('input-file');
final result = parser.run(args);
Parameters:
- name It is the command name.
- description (optional) it is the description (it affects the usage string).
Properties
- description → String
-
Description of the command
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- name → String
-
Name of the command
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
command(
String name, {String? abbr, String? help, String? description}) → Argv - Creates a subcommand under this command.
-
flag(
String name, {String? abbr, String? help, String? description, bool required = false, bool defaultTo = false}) → Argv - Method to add a flag into the current command
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
on(
ArgvCallback callback) → Argv - Attaches a callback function to this command.
-
option(
String name, {String? abbr, String? help, bool required = false, String? description, List< String> allowed = const [], String? defaultValue}) → Argv - Method to add an option into the current command.
-
positional(
String name) → Argv - Adds a positional argument to this command.
-
run(
List< String> args) → FutureOr<ArgvResult> - Parses and executes the command-line arguments.
-
set<
T extends Object> (T instance) → Argv -
Insert the
instanceinside the container -
toString(
) → String -
A string representation of this object.
inherited
-
usage(
) → String - Generates usage/help text for this command.
-
use<
T extends Object> (ArgvCallback callback(T)) → Argv - Attaches a function based on a registered service
-
validate(
FutureOr< bool> validator(ArgvResult)) → Argv - Assert that the result is valid
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited