Skip to content

Commit c381923

Browse files
authored
feat: add numCPU func (#1890)
1 parent 7bfddaa commit c381923

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

internal/templater/funcs.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@ var templateFuncs template.FuncMap
1717

1818
func init() {
1919
taskFuncs := template.FuncMap{
20-
"OS": func() string { return runtime.GOOS },
21-
"ARCH": func() string { return runtime.GOARCH },
20+
"OS": func() string { return runtime.GOOS },
21+
"ARCH": func() string { return runtime.GOARCH },
22+
"numCPU": func() int { return runtime.NumCPU() },
2223
"catLines": func(s string) string {
2324
s = strings.ReplaceAll(s, "\r\n", " ")
2425
return strings.ReplaceAll(s, "\n", " ")

website/docs/reference/templating.mdx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,8 @@ Lastly, Task itself provides a few functions:
374374
| Function | Description |
375375
| ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
376376
| `OS` | Returns the operating system. Possible values are `windows`, `linux`, `darwin` (macOS) and `freebsd`. |
377-
| `ARCH` | return the architecture Task was compiled to: `386`, `amd64`, `arm` or `s390x`. |
377+
| `ARCH` | Returns the architecture Task was compiled to: `386`, `amd64`, `arm` or `s390x`. |
378+
| `numCPU` | Returns the number of logical CPU's usable by the current process. |
378379
| `splitLines` | Splits Unix (`\n`) and Windows (`\r\n`) styled newlines. |
379380
| `catLines` | Replaces Unix (`\n`) and Windows (`\r\n`) styled newlines with a space. |
380381
| `toSlash` | Does nothing on Unix, but on Windows converts a string from `\` path format to `/`. |

0 commit comments

Comments
 (0)