Command class abstract

Command is an abstract class that defines the interface for a command. Your CLI commands will extend Command and fill out the details that they provide. Additionally, you'll have to override the run method of the command.

Implementers

Constructors

Command({required String command, String? use, List<String>? aliases, String? description, String? example, List<Command>? subcommands, Map<String, String>? supportedFlags})

Properties

aliases List<String>?
Aliases that should work the same was as the provided command name
getter/setter pair
command String
The name of the command
getter/setter pair
description String?
A description of the command, consider putting documentation here.
getter/setter pair
example String?
An example of how to run the command.
getter/setter pair
hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
subcommands List<Command>?
Any subcommands that belong under this command.
getter/setter pair
supportedFlags Map<String, String>?
Any flags that are supported and a description of their purpose. Your command can leverage flags outside of the supported flags, but this provides a way to document what flags are available for autogenerated help text.
getter/setter pair
use String?
getter/setter pair

Methods

getAllLogicalNames() List<String>
Returns a list of all possibly command names that this command should run from including the original name and all aliases
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
postRun(List<String> args, Map<String, dynamic> flags) → void
PostRun defines what code should be ran after the command is executed. Consider using this to clean up or free resources after the command is run.
preRun(List<String> args, Map<String, dynamic> flags) → void
PreRun defines what code should be ran before the command is executed. Consider using this to set things up before the command is run.
printHelp() → dynamic
Prints a small blurb about the command using properties to generate it's data.
run(List<String> args, Map<String, dynamic> flags) → void
Run defines what code should be ran when this command is executed.
toString() String
A string representation of this object.
inherited

Operators

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