ArgumentAliases.

Argument<T>(ICakeContext, string, T) Method

Summary

Gets an argument and returns the provided defaultValue if the argument is missing.
Namespace
Cake.Common
Containing Type
ArgumentAliases

Syntax

[CakeMethodAlias]
public static T Argument<T>(this ICakeContext context, string name, T defaultValue)

Examples

// Cake.exe .\argument.cake --myArgument="is valid" --loopCount=5
Information("Argument {0}", Argument<string>("myArgument", "is NOT valid"));
var loopCount = Argument<int>("loopCount", 10);
for(var index = 0;index<loopCount; index++)
{
    Information("Index {0}", index);
}

Attributes

Type Description
CakeMethodAliasAttribute An attribute used to mark script method aliases.

Type Parameters

Name Description
T The argument type.

Parameters

Name Type Description
context ICakeContext The context.
name string The argument name.
defaultValue T The value to return if the argument is missing.

Return Value

Type Description
T The value of the argument if it exist; otherwise defaultValue.