OptionDefinition class

Definition of a CLI option.

Used to declare options for tools and commands, enabling automatic help generation, argument parsing, and shell completion.

Constructors

OptionDefinition({required String name, String? abbr, required String description, OptionType type = OptionType.flag, String? defaultValue, List<String>? allowedValues, bool mandatory = false, bool negatable = false, String? valueName, bool hidden = false})
const
OptionDefinition.flag({required String name, String? abbr, required String description, String? defaultValue, bool negatable = false, bool hidden = false})
Create a flag option.
const
OptionDefinition.multi({required String name, String? abbr, required String description, List<String>? allowedValues, bool mandatory = false, String? valueName, bool hidden = false})
Create a multi-value option.
const
OptionDefinition.option({required String name, String? abbr, required String description, String? defaultValue, List<String>? allowedValues, bool mandatory = false, String? valueName, bool hidden = false})
Create a single-value option.
const

Properties

abbr String?
Short abbreviation (single character, e.g., 'v', 'c').
final
allowedValues List<String>?
Allowed values (for validation and completion).
final
defaultValue String?
Default value (as string, null if no default).
final
description String
Human-readable description for help text.
final
hashCode int
The hash code for this object.
no setterinherited
hidden bool
Whether this option is hidden from help.
final
mandatory bool
Whether this option is mandatory.
final
name String
Option name (without dashes, e.g., 'verbose', 'config').
final
negatable bool
Whether flag can be negated (--no-X).
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
type OptionType
Type of option (flag, option, multiOption).
final
usage String
Format for help text (e.g., '-v, --verbose').
no setter
valueName String?
Value name for help text (e.g., 'path', 'pattern').
final

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
override

Operators

operator ==(Object other) bool
The equality operator.
inherited