Show / Hide Table of Contents

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.

Inheritance
object
Attribute
CommandAliasAttribute
Inherited Members
Attribute.Equals(object)
Attribute.GetCustomAttribute(Assembly, Type)
Attribute.GetCustomAttribute(Assembly, Type, bool)
Attribute.GetCustomAttribute(MemberInfo, Type)
Attribute.GetCustomAttribute(MemberInfo, Type, bool)
Attribute.GetCustomAttribute(Module, Type)
Attribute.GetCustomAttribute(Module, Type, bool)
Attribute.GetCustomAttribute(ParameterInfo, Type)
Attribute.GetCustomAttribute(ParameterInfo, Type, bool)
Attribute.GetCustomAttributes(Assembly)
Attribute.GetCustomAttributes(Assembly, bool)
Attribute.GetCustomAttributes(Assembly, Type)
Attribute.GetCustomAttributes(Assembly, Type, bool)
Attribute.GetCustomAttributes(MemberInfo)
Attribute.GetCustomAttributes(MemberInfo, bool)
Attribute.GetCustomAttributes(MemberInfo, Type)
Attribute.GetCustomAttributes(MemberInfo, Type, bool)
Attribute.GetCustomAttributes(Module)
Attribute.GetCustomAttributes(Module, bool)
Attribute.GetCustomAttributes(Module, Type)
Attribute.GetCustomAttributes(Module, Type, bool)
Attribute.GetCustomAttributes(ParameterInfo)
Attribute.GetCustomAttributes(ParameterInfo, bool)
Attribute.GetCustomAttributes(ParameterInfo, Type)
Attribute.GetCustomAttributes(ParameterInfo, Type, bool)
Attribute.GetHashCode()
Attribute.IsDefaultAttribute()
Attribute.IsDefined(Assembly, Type)
Attribute.IsDefined(Assembly, Type, bool)
Attribute.IsDefined(MemberInfo, Type)
Attribute.IsDefined(MemberInfo, Type, bool)
Attribute.IsDefined(Module, Type)
Attribute.IsDefined(Module, Type, bool)
Attribute.IsDefined(ParameterInfo, Type)
Attribute.IsDefined(ParameterInfo, Type, bool)
Attribute.Match(object)
Attribute.TypeId
object.Equals(object, object)
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: Benday.CommandsFramework
Assembly: Benday.CommandsFramework.dll
Syntax
[AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
public class CommandAliasAttribute : Attribute

Constructors

| Edit this page View Source

CommandAliasAttribute(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 Source

Arguments

Argument values supplied by this alias, each in 'name=value' form.

Declaration
public string[] Arguments { get; }
Property Value
Type Description
string[]
| Edit this page View Source

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
| Edit this page View Source

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 Source

GetArgumentValues()

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

  • Edit this page
  • View Source
In this article
Back to top Copyright © www.benday.com | info@benday.com