Skip to content

Commit

Permalink
docs: add an example of a default value usage in vars (#1893)
Browse files Browse the repository at this point in the history
  • Loading branch information
iamkarlson authored Nov 1, 2024
1 parent fe09c01 commit 47f5e6a
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions website/docs/usage.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -1212,6 +1212,28 @@ tasks:
- echo "{{.GREETING}}"
```

Example of a `default` value to be overriden from CLI:

```yaml
version: '3'
greet_user:
desc: "Greet the user with a name."
vars:
USER_NAME: '{{.USER_NAME| default "DefaultUser"}}'
cmds:
- echo "Hello, {{.USER_NAME}}!"
```

```shell
$ task greet_user
task: [greet_user] echo "Hello, DefaultUser!"
Hello, DefaultUser!
$ task greet_user USER_NAME="Bob"
task: [greet_user] echo "Hello, Bob!"
Hello, Bob!
```

### Dynamic variables

The below syntax (`sh:` prop in a variable) is considered a dynamic variable.
Expand Down

0 comments on commit 47f5e6a

Please sign in to comment.