Skip to content

Commit 9d8294a

Browse files
committed
Add numCPU func
1 parent c4f708b commit 9d8294a

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
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: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,7 @@ Lastly, Task itself provides a few functions:
375375
| ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
376376
| `OS` | Returns the operating system. Possible values are `windows`, `linux`, `darwin` (macOS) and `freebsd`. |
377377
| `ARCH` | return 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 `/`. |

website/versioned_docs/version-latest/reference/templating.mdx

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

0 commit comments

Comments
 (0)