mirror of
https://github.com/go-task/task.git
synced 2025-08-08 22:36:57 +02:00
README: Document recent changes
This commit is contained in:
21
README.md
21
README.md
@ -46,6 +46,7 @@ run in Bash, otherwise will fallback to `cmd` (on Windows).
|
|||||||
If you ommit a task name, "default" will be assumed.
|
If you ommit a task name, "default" will be assumed.
|
||||||
|
|
||||||
### Environment
|
### Environment
|
||||||
|
|
||||||
You can specify environment variables that are added when running a command:
|
You can specify environment variables that are added when running a command:
|
||||||
|
|
||||||
```yml
|
```yml
|
||||||
@ -269,8 +270,18 @@ build:
|
|||||||
### Go's template engine
|
### Go's template engine
|
||||||
|
|
||||||
Task parse commands as [Go's template engine][gotemplate] before executing
|
Task parse commands as [Go's template engine][gotemplate] before executing
|
||||||
them. Variables are acessible through dot syntax (`.VARNAME`). The following
|
them. Variables are acessible through dot syntax (`.VARNAME`).
|
||||||
functions are available:
|
|
||||||
|
All functions by the Go's [sprig lib](http://masterminds.github.io/sprig/)
|
||||||
|
are available. The following example gets the current date in a given format:
|
||||||
|
|
||||||
|
```go
|
||||||
|
print-date:
|
||||||
|
cmds:
|
||||||
|
- echo {{now | date "2006-01-02"}}
|
||||||
|
```
|
||||||
|
|
||||||
|
Task also adds the following functions:
|
||||||
|
|
||||||
- `OS`: return operating system. Possible values are "windows", "linux",
|
- `OS`: return operating system. Possible values are "windows", "linux",
|
||||||
"darwin" (macOS) and "freebsd".
|
"darwin" (macOS) and "freebsd".
|
||||||
@ -280,6 +291,10 @@ functions are available:
|
|||||||
return `true` if `sh` command was found (Git Bash). In this case commands
|
return `true` if `sh` command was found (Git Bash). In this case commands
|
||||||
will run on `sh`. Otherwise, this function will return `false` meaning
|
will run on `sh`. Otherwise, this function will return `false` meaning
|
||||||
commands will run on `cmd`.
|
commands will run on `cmd`.
|
||||||
|
- `ToSlash`: Does nothing on `sh`, but on `cmd` converts a string from `\`
|
||||||
|
path format to `/`.
|
||||||
|
- `FromSlash`: Oposite of `ToSlash`. Does nothing on `sh`, but on `cmd`
|
||||||
|
converts a string from `\` path format to `/`.
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
@ -289,6 +304,8 @@ printos:
|
|||||||
- echo '{{OS}} {{ARCH}}'
|
- echo '{{OS}} {{ARCH}}'
|
||||||
- "echo '{{if eq OS \"windows\"}}windows-command{{else}}unix-command{{end}}'"
|
- "echo '{{if eq OS \"windows\"}}windows-command{{else}}unix-command{{end}}'"
|
||||||
- echo 'Is SH? {{IsSH}}'
|
- echo 'Is SH? {{IsSH}}'
|
||||||
|
# This will be ./bin/executable on sh but .\bin\executable on cmd
|
||||||
|
- "{{FromSlash \"./bin/executable\"}}"
|
||||||
```
|
```
|
||||||
|
|
||||||
### Help
|
### Help
|
||||||
|
Reference in New Issue
Block a user