Skip to content

Commit

Permalink
Merge pull request #43 from tofuutils/docs/version-name
Browse files Browse the repository at this point in the history
docs: add description for tofuenv version-name and pin commands
  • Loading branch information
Nmishin committed Jan 23, 2024
2 parents 16938b0 + f5d92f6 commit 4abbd99
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 9 deletions.
3 changes: 3 additions & 0 deletions .changelog/43.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
documentation: add description for tofuenv version-name and pin commands
```
21 changes: 19 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -497,9 +497,26 @@ $ tofuenv list-remote
...
```

## .opentofu-version file
### tofuenv version-name
Prints the version of OpenTofu, used in the current directory.
The version is resolved automatically via [TOFUENV_TOFU_VERSION environment variable](#TOFUENV_TOFU_VERSION) or [.opentofu-version files](#opentofu-version-file), in that order of precedence, i.e. TOFUENV_TOFU_VERSION, then .opentofu-version.
```console
$ tofuenv version-name
1.6.0
```

### tofuenv pin
Writes the current active OpenTofu version to ./.opentofu-version file (creates if no file exists).
```console
$ tofuenv pin
Pinned version by writing "1.6.0" to /Users/anastasiiakozlova/coding/opensource/tofuenv/.opentofu-version
$ cat .opentofu-version
1.6.0
```

#### .opentofu-version file

If you put a `.opentofu-version` file on your project root, or in your home directory, tofuenv detects it and uses the version written in it. If the version is `latest` or `latest:<regex>`, the latest matching version currently installed will be selected.
If you put a `.opentofu-version` file on your project root, or in your home directory (automatically using `tofuenv pin` command or manually), tofuenv detects it and uses the version written in it. If the version is `latest` or `latest:<regex>`, the latest matching version currently installed will be selected.

Note, that [TOFUENV_TOFU_VERSION environment variable](#TOFUENV_TOFU_VERSION) can be used to override version, specified by `.opentofu-version` file.

Expand Down
19 changes: 12 additions & 7 deletions libexec/tofuenv-help
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,22 @@

set -uo pipefail;

echo 'Usage: tofuenv <command> [<options>]
echo 'Usage: tofuenv [<global options>] <command> [<options>]
Commands:
install Install a specific version of OpenTofu
use Switch a version to use
use Switch an OpenTofu version to use
uninstall Uninstall a specific version of OpenTofu
list List all installed versions
list-remote List all installable versions
version-name Print current version of OpenTofu
init Update environment to use 'tofuenv' correctly.
pin Write the current active version to ./.opentofu-version
list List all installed versions of OpenTofu
list-remote List all OpenTofu versions available for installation
version-name Print currently used version of OpenTofu
init Update PATH with 'tofuenv' executable path (for current session only)
pin Write the current active OpenTofu version to ./.opentofu-version
help Show this help output
Global options:
--version Print current version of tofuenv
--help Show this help output
';

exit 0;

0 comments on commit 4abbd99

Please sign in to comment.