v0.8.3
v0.8.3 main v0.8.5 v0.8.4 v0.8.2 v0.8.1 v0.8.0

Inputs

[edit]
You are looking at the docs for an older version (v0.8.3). The latest version is main.

How to define inputs to a task

Some tasks will require inputs such as the name of servers, paths to files, or credentials.

xc tasks are executed as shell scripts, so they support shell syntax for variables.

xc [task-name] [inputs...]

Syntax - Named Inputs

The Inputs attribute can be used to denote required parameters, which at runtime will be converted to environment variables.

## Tasks
### greet

Inputs: FORENAME, SURNAME

```
echo "Hello, $FORENAME $SURNAME."
```

Named Inputs can be passed via command arguments:

$ xc greet Joe Bloggs
+ echo 'Hello, Joe Bloggs.'
Hello, Joe Bloggs.

Or via environment variables:

$ export FORENAME=Joe
$ export SURNAME=Bloggs
$ xc greet
+ echo 'Hello, Joe Bloggs.'
Hello, Joe Bloggs.

xc will return an error if Inputs are not passed:

$ xc greet
Task has required inputs:
        xc greet <forename> <surname>
        FORENAME=<forename> SURNAME=<surname> xc greet
exit status 1

Syntax - Optional Inputs

Combining the Environment attribute and the Inputs attribute, you can create optional inputs to a task.

## Tasks
### greet

Inputs: NAME
Environment: NAME=World

```
echo "Hello, $NAME."
```

Can be ran as:

$ xc greet Joe
+ echo 'Hello, Joe.'
Hello, Joe.

or

$ xc greet
+ echo 'Hello, World.'
Hello, World.

Syntax - Positional

As xc tasks are executed as shell scripts you can also use positional syntax of arguments.

(xc will not return an error if a script uses positional syntax and the input is not provided)

## Tasks
### greet
```
echo "Hello, $1."
```

Can be ran as:

$ xc greet Joe
+ echo 'Hello, Joe.'
Hello, Joe.

Syntax - Variadic

As xc tasks are executed as shell scripts you can also use variadic syntax of arguments.

(xc will not return an error if a script uses variadic syntax and no inputs are provided)

## Tasks
### greet-everyone
```
echo "Hello, $@."
```

Can be ran as:

$ xc greet Joe Bob Steve
+ echo 'Hello, Joe Bob Steve.'
Hello, Joe Bob Steve.