Custom Commands
One design goal for Revolver was to be a platform for custom tool development and allow users to create their own commands.
Defining a Command
Revolver commands must implement the Revolver.Core.Commands.ICommand, Revolver.Core
interface. As a convenience commands may subclass Revolver.Core.Commands.BaseCommand, Revolver.Core
which implements the interface and handles initialisation.
Command Arguments
Arguments passed to the command through the command line are automatically mapped to properties of the command class. Attributes are used to facilitate this mapping and control how it’s performed.
The following attributes are supported:
- Revolver.Core.Commands.DescriptionAttribute
- Provides a description of the command which is used in the help system.
- Revolver.Core.Commands.FlagParameterAttribute
- For boolean properties. This argument is either present or not.
- Revolver.Core.Commands.ListParameterAttribute
- For `IList
` properties. Collects all unmatched arguments from the argument list. - Revolver.Core.Commands.NamedParameterAttribute
- For arguments passed by name.
- Revolver.Core.Commands.NoSubstitutionAttribute
- Indicates token substitution should not be performed for the property.
- Revolver.Core.Commands.NumberedParameterAttribute
- For arguments passed in order.
- Revolver.Core.Commands.OptionalAttribute
- Indicates the argument is optional. Only used as an indicator in the help system, not enforced by the parser.
Example
Here’s a quick example of a custom command that uses automatic argument mapping.
1 | public class MyCommand : BaseCommand |
Reference
The best reference available for implementing commands in Revolver would be the Revolver source itself. Have a look over the commands at https://github.com/codeflood/revolver/tree/master/Revolver.Core/Commands