Skip to content

Commit

Permalink
feat: add .Arch template variable
Browse files Browse the repository at this point in the history
resolves #63
  • Loading branch information
JanDeDobbeleer committed Nov 4, 2023
1 parent effb5a9 commit 840efbb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
2 changes: 2 additions & 0 deletions src/context/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@ type Runtime struct {
Shell string
OS string
Home string
Arch string
}

func Init(shell string) {
Current = &Runtime{
Shell: shell,
OS: runtime.GOOS,
Arch: runtime.GOARCH,
Home: Home(),
}
}
Expand Down
15 changes: 8 additions & 7 deletions website/docs/setup/templates.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@ configuration across multiple environments resulting in environment specific val
Out of the box you get the following functionality:
| Name | Type | Description | Example |
| -------- | ---------- | ----------------------------------------------------------- | ---------------------------------------------------------------- |
| `.Shell` | `string` | the current shell name | `{{ .Shell }}` |
| `.Home` | `string` | the user's `$HOME` folder | `{{ .Home }}/go/bin/aliae` |
| `.OS` | `string` | the current operating system (`windows`, `darwin`, `linux`) | `{{ .Home }}/go/bin/aliae{{ if eq .OS "windows" }}.exe{{ end }}` |
| `env` | `function` | retrieve an environment variable value | `{{ env "POSH_THEME" }}` |
| `match` | `function` | match a shell name to one or multiple options | `{{ match .Shell "zsh" "bash" }}` |
| Name | Type | Description | Example |
| -------- | ---------- | ----------------------------------------------------------- | ---------------------------------------------------------------------------- |
| `.Shell` | `string` | the current shell name | `{{ .Shell }}` |
| `.Home` | `string` | the user's `$HOME` folder | `{{ .Home }}/go/bin/aliae` |
| `.OS` | `string` | the current operating system (`windows`, `darwin`, `linux`) | `{{ .Home }}/go/bin/aliae{{ if eq .OS "windows" }}.exe{{ end }}` |
| `.Arch` | `string` | the `aliae` executable's compiled architecture | `{{ .Home }}/go/bin/aliae-{{ .Arch }}{{ if eq .OS "windows" }}.exe{{ end }}` |
| `env` | `function` | retrieve an environment variable value | `{{ env "POSH_THEME" }}` |
| `match` | `function` | match a shell name to one or multiple options | `{{ match .Shell "zsh" "bash" }}` |

[go-text-template]: https://golang.org/pkg/text/template/

0 comments on commit 840efbb

Please sign in to comment.