All pages
Powered by GitBook
1 of 1

Loading...

Passing Parameters

A task target can defined as many method arguments as it wants which can be passed in via command arguments when calling the task.

fun.cfc

There's two ways to pass in the name and verbose parameters: positionally and via named parameters.

Positional

If you want to pass your parameters positionally, you must include the task and target name.

Named

A more self-documenting method is to use named parameters. Note, it is not necessary to pass the task and target name when using named parameters, but in this case, my example does not use the default task and target convention names, so I'll need to pass them anyway. Note that we start each parameter name with a colon (:) so they don't interfere with any of the parameters to the actual task run command.

The parameters :name and :verbose will be passed directly along to the task as name and verbose.

Flags

Tasks with boolean parameters can also have those passed using flags just like commands. Simply prepend a colon (:) to the name of the flag like so.

Mix it up

Since task run is just a regular command, remember its parameters don't have to be hard coded. They can expressions or system settings, etc.

component{
    function greet( string name, boolean verbose ){
        print.line( 'Well, hello there #name#!' );
        if( verbose ) {
            print.line( "You're looking quite well today." );
        }
    }
}
task run fun greet Brad false
task run taskFile=fun target=greet :name=Brad :verbose=false
task run --no:verbose
or
task run --!:verbose
task run ${APIDocURL} ${APIDocPort:8080}
task run taskFile=build :message=`cat message.txt`