#terraform #cli #opentofu #tfswitch

app tfswitcher

A Terraform and OpenTofu version switcher

12 releases (5 breaking)

0.7.0 Jan 25, 2024
0.6.0 Dec 23, 2023
0.5.0 Nov 19, 2023
0.2.3 Jul 25, 2023

#803 in Command line utilities

Download history 6/week @ 2023-12-31 7/week @ 2024-01-21 1/week @ 2024-01-28 48/week @ 2024-02-25 1/week @ 2024-03-10 5/week @ 2024-03-31 107/week @ 2024-04-07

112 downloads per month

MIT license

38KB
849 lines

tfswitcher

Terraform and OpenTofu version switcher written in Rust.

Installation

Homebrew

To install via Homebrew, run:

brew install asleepycat/tap/tfswitcher

This will build from source.

Cargo

To install with cargo, run:

cargo install tfswitcher

There are also prebuilt binaries available with each release for Linux, macOS and Windows.

Usage

To see available flags and arguments, run tfswitcher -h or tfswitcher --help.

You can also use a configuration file to automatically set certain flags or arguments. Simply place a file called .tfswitch.toml either in your current working directory or in your $HOME directory.

bin = "$HOME/.local/bin/terraform"
list_all = false
opentofu = false
force_remove = false
verbose = false
version = "1.0.0"

Shell Completions

tfswitcher can generate tab-completion scripts for your desired shell. To see which shells are supported, see the --help text.

For example, for Bash:

tfswitcher -c bash >> ~/.local/share/bash-completion/completions/tfswitcher

Alternatively, you can source the tab-completion script inside your shell's start up script:

echo "source <(tfswitcher -c bash)" >> ~/.bashrc

Caveats

This has not been tested on Windows or macOS, so YMMV.

Where's v0.1.0?

v0.1.0 used FFI with Cgo in order to use HashiCorp's terraform-config-inspect library. This was inadvertently published as the Windows and macOS builds were broken and is yanked.

v0.2.0 replaced the Go library with a partially-reimplemented Rust library to eliminate FFI and makes building for Windows and macOS a lot less painful.

Dependencies

~27–43MB
~718K SLoC