Class CommandAliasAttribute
Add this attribute to a command class to create an alternate name for the command that also supplies argument values. This is useful for creating a shortcut for a command that is usually run with the same set of arguments.
[Command(Name = "deploy")]
[CommandAlias("deploy-prod", "environment=production", "verbose=true",
Description = "Deploy to production")]
public class DeployCommand : SynchronousCommand
The argument values are applied as though they had been typed on the command line, so anything actually supplied on the command line wins over them. The resulting order of precedence is: command line, then alias, then configuration, then the argument's default value.
Inherited Members
Namespace: Benday.CommandsFramework
Assembly: Benday.CommandsFramework.dll
Syntax
[AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
public class CommandAliasAttribute : Attribute
Constructors
| Edit this page View SourceCommandAliasAttribute(string, params string[])
Constructor
Declaration
public CommandAliasAttribute(string name, params string[] arguments)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | The alias that gets typed on the command line |
| string[] | arguments | Argument values supplied by this alias, each in 'name=value' form. An entry with no '=' is treated as an argument with an empty value, which is how flag style boolean arguments are supplied. |
Properties
| Edit this page View SourceArguments
Argument values supplied by this alias, each in 'name=value' form.
Declaration
public string[] Arguments { get; }
Property Value
| Type | Description |
|---|---|
| string[] |
Description
Human readable description of what this alias does. Shown in the list of available command aliases.
Declaration
public string Description { get; set; }
Property Value
| Type | Description |
|---|---|
| string |
Name
The alias that gets typed on the command line in place of the command name.
Declaration
public string Name { get; }
Property Value
| Type | Description |
|---|---|
| string |
Methods
| Edit this page View SourceGetArgumentValues()
Parses the 'name=value' entries in Arguments into argument names and values.
Declaration
public Dictionary<string, string> GetArgumentValues()
Returns
| Type | Description |
|---|---|
| Dictionary<string, string> | Argument names and values supplied by this alias |