Skip to content

Arguments

Roman edited this page Aug 23, 2022 · 4 revisions

Tasks can have arguments passed to them.

To pass arguments, just add them when calling the task from the cli: --argumentname=argumentvalue

You can also just use flags like -x. There, the value is just true if they were passed and they are nonexistent otherwise.

In your task, you can then check if a specific argument was set and get the value of a specific argument.

Example:

// The value will be an empty string if the argument does not exist
value := gotaskr.GetArgument("name")

// The value will be "defaultValue" if the argument does not exist
valueOrDefault: gotaskr.GetArgumentOrDefault("name", "defaultValue")

// Useful for just checking flags
argumentIsSet := gotaskr.HasArgument("x")
Clone this wiki locally