From b9ec4e9551e954a613bb575fca3043e33ebeacdd Mon Sep 17 00:00:00 2001 From: Abyss Date: Wed, 19 Jun 2024 11:31:47 -0500 Subject: [PATCH] chore: Clean up README --- README.md | 17 +++++++++-------- tfws.go | 4 ---- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index af95ea7..af6d94f 100644 --- a/README.md +++ b/README.md @@ -2,9 +2,6 @@ The Terraform Workspace Selector is a command-line tool that helps you interactively select a Terraform workspace from the available options. -I generated this entirely using ChatGPT and don't know what I'm doing, so there might be problems or inefficiencies. Feel free to open issues. - - ## Functionality The application provides the following basic functionality: @@ -13,14 +10,18 @@ The application provides the following basic functionality: - Displays an interactive prompt that allows you to select a workspace. - Sets the selected workspace using the `terraform workspace select` command. +## Install -## Usage +To install Terraform Workspace Selector, you can do either of the following: +- Run `go install github.com/abyss/tfws@latest` -To use the Terraform Workspace Selector, follow these steps: +- Download a binary from GitHub and put it in your PATH + +`tfws` calls `terraform` directly, so terraform will need to be resolvable from your path. Tools like [tenv](https://github.com/tofuutils/tenv) or [asdf](https://github.com/asdf-vm/asdf) should natively work. + +## Usage -1. Run `task build` to create a binary (located in `bin/`) -2. Copy that binary somewhere in your path. -3. Run `tfws` in your Terraform project. +To use the Terraform Workspace Selector, just run `tfws` in a Terraform project with multiple workspaces. Upon running the application, it will retrieve the list of Terraform workspaces and display an interactive prompt. Use the arrow keys or fuzzy search to navigate the options and press Enter to select a workspace. The selected workspace will be set using the `terraform workspace select` command. diff --git a/tfws.go b/tfws.go index 10a7c36..c062239 100644 --- a/tfws.go +++ b/tfws.go @@ -47,7 +47,6 @@ func main() { return } - // Create items for the prompt items := make([]string, len(validWorkspaces)) defaultIndex := 0 for i, workspace := range validWorkspaces { @@ -57,14 +56,12 @@ func main() { } } - // Create the select prompt prompt := &survey.Select{ Message: "Select a Terraform workspace:", Options: items, Default: items[defaultIndex], } - // Run the prompt var selectedWorkspace string err = survey.AskOne(prompt, &selectedWorkspace, survey.WithPageSize(10)) if err != nil { @@ -73,7 +70,6 @@ func main() { fmt.Printf("Selected workspace: %s\n", selectedWorkspace) - // Select the chosen workspace cmd = exec.Command("terraform", "workspace", "select", selectedWorkspace) if err := cmd.Run(); err != nil { log.Fatalf("Failed to execute 'terraform workspace select': %s", err)