CommandSignature class
Laravel-style command signature DSL parser.
A signature compresses the command name + every positional argument + every option/flag into a single string declared on the command class. The dispatcher parses it once at registration time, applies the declarations to the underlying ArgParser, and exposes the argument names so ArtisanInput.argument can look up by name (not just index).
Grammar
signature := name (whitespace token)*
name := lowercase-kebab-case-with-optional:colon-namespace
token := '{' (argument | option) '}'
argument := name [modifier] [' : ' description]
option := '--' name [value-spec] [' : ' description]
modifier := '?' // optional
| '*' // variadic
| '?*' // optional variadic
| '=' default // positional with default
value-spec := '=' // required value, no default
| '=' default // option with default
Examples
'sync-monitors'
'sync:monitors {team}'
'sync:monitors {team?}'
'sync:monitors {team=acme}'
'sync:monitors {team*}'
'sync:monitors {--force}'
'sync:monitors {--limit=10}'
'sync:monitors {team : Team slug} {--force : Skip prompts}'
Constructors
-
CommandSignature({required String name, required List<
ArgumentSpec> arguments, required List<OptionSpec> options}) - CommandSignature.parse(String input)
-
Parse a signature string. Throws FormatException when the syntax
does not match the grammar above.
factory
Properties
-
arguments
→ List<
ArgumentSpec> -
Positional argument specs in declaration order.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- name → String
-
Dispatch name (e.g.
sync-monitors,mail:send-digest).final -
options
→ List<
OptionSpec> -
Option / flag specs in declaration order.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
applyTo(
ArgParser parser) → void -
Apply this signature to
parserso the underlying args package recognises the declared options/flags. Positional arguments stay in the parser'srestand are mapped to names via ArgumentSpec. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited