ArgumentBinderAliases.

ArgumentConfigToString<T>(ICakeContext, T) Method

Summary

Takes in an object that has arguments binded to it, and creates a string-representation of the class.

Syntax

public static string ArgumentConfigToString<T>(this ICakeContext context, T obj)

Examples

This prints the values for each property that has a IReadOnlyArgumentAttribute bound to it that the user passed in.

public class MyConfig
    {
        [BooleanArgument(
            "dry_run",
            Description = "Set to 'true' to not do anything.",
            DefaultValue = false
        )]
        public bool DryRun { get; set; }
    }
    
    MyConfig config = CreateFromArguments<MyConfig>();
    Information( ArgumentConfigToString( config ) );
    
    // If cake --dry_run is set to true, this is what will be printed out:
    //
    // MyConfig's Configuration:
    //      -dry_run: True

Remarks

This is an extension of ICakeContext, which means unless your config object has a reference to a ICakeContext, you can't call this function in a config object's ToString() function. If you *want* to do that, call ConfigToStringHelper<T>(T) directly (though you may need a "using Cake.ArgumentBinder" statement for that). Also, obviously, if the given object has no arguments binded to it, this isn't going to be helpful.

Attributes

Type Description
CakeMethodAliasAttribute
CakeAliasCategoryAttribute
CakeNamespaceImportAttribute

Type Parameters

Name Description
T The type of class that has arguments bounded to it.

Parameters

Name Type Description
context ICakeContext
obj T The type object to get the string of.

Return Value

Type Description
string A string that shows what the user passed into the class.