ParentCommand Class

Base class for subcommands that have nested subcommands.

Definition

Namespace: Ookii.CommandLine.Commands
Assembly: Ookii.CommandLine (in Ookii.CommandLine.dll) Version: 4.0.0+bb7ed9a8fdfd1cb21824750a8cf508863ad15086
C#
public abstract class ParentCommand : ICommandWithCustomParsing, 
	ICommand, IAsyncCommand
Inheritance
Object    ParentCommand
Implements
IAsyncCommand, ICommand, ICommandWithCustomParsing

Remarks

The ParentCommand class, along with the ParentCommandAttribute attribute, aid in easily creating applications that contain nested subcommands. This class handles finding, creating and running any nested subcommands, and handling parsing errors and printing usage help for those subcommands.

To utilize this class, derive a class from this class and apply the CommandAttribute attribute to that class. Then, apply the ParentCommandAttribute attribute to any child commands of this command.

Often, the derived class can be empty; however, you can override the members of this class to customize the behavior.

The ParentCommand class is based on the ICommandWithCustomParsing interface, so derived classes cannot define any arguments or use other functionality that depends on the CommandLineParser class.

Constructors

ParentCommandInitializes a new instance of the ParentCommand class

Properties

FailureExitCode Gets the exit code to return from the Run or RunAsync method if parsing command line arguments for a nested subcommand failed.

Methods

EqualsDetermines whether the specified object is equal to the current object.
(Inherited from Object)
FinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object)
GetHashCodeServes as the default hash function.
(Inherited from Object)
GetTypeGets the Type of the current instance.
(Inherited from Object)
MemberwiseCloneCreates a shallow copy of the current Object.
(Inherited from Object)
OnAfterParsing Function called after parsing, on success, cancellation, and failure.
OnChildCommandNotFound Method called when no nested subcommand name was specified, or the nested subcommand could not be found.
OnDuplicateArgumentWarning Method called when the ParseOptionsDuplicateArguments property is set to ErrorModeWarning and a duplicate argument value was encountered.
OnModifyOptions Allows derived classes to customize the command and parse options used for the nested subcommands.
Parse Parses the arguments for the command, locating and instantiating a child command.
Run Runs the child command that was instantiated by the Parse(ReadOnlyMemoryString, CommandManager) method.
RunAsync Runs the child command that was instantiated by the Parse(ReadOnlyMemoryString, CommandManager) method asynchronously.
ToStringReturns a string that represents the current object.
(Inherited from Object)

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also