Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
89 commits
Select commit Hold shift + click to select a range
929ff3f
toolchain installer experiment
osterman Jul 23, 2025
3cef77b
wip
osterman Jul 24, 2025
8377c82
fix tests
osterman Jul 24, 2025
5684420
clean install/uninstall ui
osterman Jul 24, 2025
dc108c5
rename from packages to tools
osterman Jul 24, 2025
00fcc37
add types
osterman Jul 24, 2025
ede6dbd
wip
osterman Jul 25, 2025
08bb8e2
wip
osterman Jul 27, 2025
ef9e072
wip gui
osterman Jul 27, 2025
c85671a
wip
osterman Jul 27, 2025
7228903
wip
osterman Jul 27, 2025
a5f0bde
uninstall all versions
osterman Jul 28, 2025
06fb8b6
uninstall all versions
osterman Jul 28, 2025
b32c16a
fix tests
osterman Jul 28, 2025
0dfb620
fix tests
osterman Jul 28, 2025
f6d6fa6
fix tests
osterman Jul 28, 2025
f0c5c42
clean cache and fix spinners
osterman Jul 28, 2025
429e311
wip list command
osterman Jul 28, 2025
813da01
[autofix.ci] apply automated fixes
autofix-ci[bot] Jul 31, 2025
9678326
Merge branch 'main' into tools-experiment
samtholiya Jul 31, 2025
46e7776
integrate toolchain to atmos core
samtholiya Aug 7, 2025
3641f28
[autofix.ci] apply automated fixes
autofix-ci[bot] Aug 7, 2025
93cba98
Merge branch 'main' into tools-experiment
samtholiya Aug 7, 2025
2032866
toolchain migration
samtholiya Aug 21, 2025
9536b16
[autofix.ci] apply automated fixes
autofix-ci[bot] Aug 21, 2025
d3878a3
fix test cases
samtholiya Aug 22, 2025
00b5724
update valid version for macos
samtholiya Aug 24, 2025
7b2ee9d
remove toolchain binary
samtholiya Aug 24, 2025
2271fea
Merge branch 'main' into tools-experiment
samtholiya Aug 26, 2025
cfc9a64
Merge branch 'main' into tools-experiment
samtholiya Aug 28, 2025
b88cd0b
screen grabs with documentation example
samtholiya Aug 28, 2025
bc0d937
add documentation
samtholiya Aug 31, 2025
18fc85f
add tempdir log
samtholiya Aug 31, 2025
df22df1
[autofix.ci] apply automated fixes
autofix-ci[bot] Aug 31, 2025
0afbd37
try to fix temp dir
samtholiya Aug 31, 2025
b2ed865
fix test
samtholiya Aug 31, 2025
784162f
fix test
samtholiya Aug 31, 2025
785f7fd
check error message
samtholiya Aug 31, 2025
f21bc6c
increasae coverage
samtholiya Aug 31, 2025
21e008b
try to fix the test
samtholiya Aug 31, 2025
121f12b
toolchain install document
samtholiya Sep 4, 2025
bb4fb0e
add toolchain add and get documentation
samtholiya Sep 4, 2025
ba3b5e6
update help for toolchain install
samtholiya Sep 4, 2025
a23abb4
atmos toolchain versions screenshot update
samtholiya Sep 4, 2025
bbcbc3a
update toolchain help
samtholiya Sep 4, 2025
85e4392
fix help
samtholiya Sep 4, 2025
bb7e62f
example updated
samtholiya Sep 5, 2025
6336466
add documentation
samtholiya Sep 5, 2025
94e0a56
Merge branch 'main' into tools-experiment
samtholiya Sep 5, 2025
2a5d08d
update documentation
samtholiya Sep 7, 2025
bef2ef5
update documentation
samtholiya Sep 7, 2025
859c1f1
updated cli
samtholiya Sep 7, 2025
f8079eb
which toolchain update readme
samtholiya Sep 7, 2025
c9cd2b3
update which documentation
samtholiya Sep 7, 2025
c7badf1
add command documentation update
samtholiya Sep 7, 2025
a3cbba5
aliases documentation update
samtholiya Sep 7, 2025
f97d048
add commands
samtholiya Sep 7, 2025
1bce6de
model tests udpated
samtholiya Sep 7, 2025
df0ad9c
[autofix.ci] apply automated fixes
autofix-ci[bot] Sep 7, 2025
248a452
Update toolchain/clean.go
samtholiya Sep 7, 2025
3c0f957
update exec help content
samtholiya Sep 7, 2025
c4434d2
lint
samtholiya Sep 7, 2025
cabceb4
fix lint
samtholiya Sep 7, 2025
0cca05f
Merge branch 'main' into tools-experiment
samtholiya Sep 7, 2025
8a1bcb9
improve help
samtholiya Sep 10, 2025
2c04234
[autofix.ci] apply automated fixes
autofix-ci[bot] Sep 10, 2025
c20d17e
fix http client rabbit
samtholiya Sep 11, 2025
2af6936
Update cmd/markdown/atmos_toolchain_list.md
samtholiya Sep 11, 2025
aa02ad2
Merge branch 'main' into tools-experiment
samtholiya Sep 13, 2025
3d86485
Update toolchain/installer.go
samtholiya Sep 13, 2025
53b5836
lint issues fix
samtholiya Sep 13, 2025
1ec5454
fix description
samtholiya Sep 13, 2025
ebafb50
Update toolchain/installer.go
samtholiya Sep 13, 2025
1c10323
Update cmd/toolchain_get.go
samtholiya Sep 13, 2025
32f6404
fix the suggestion
samtholiya Sep 13, 2025
8db7731
toolchain version
samtholiya Sep 13, 2025
7871d64
fix errors
samtholiya Sep 13, 2025
9dfe495
fix test case
samtholiya Sep 14, 2025
48adbc0
fix test
samtholiya Sep 14, 2025
9a52373
remove unwanted function
samtholiya Sep 14, 2025
91214a5
fix windows test
samtholiya Sep 14, 2025
a7bc3ca
Merge branch 'main' into tools-experiment
samtholiya Sep 19, 2025
480e43b
fix windows command
samtholiya Sep 19, 2025
672fd20
updated zip extractor to notive golang
samtholiya Sep 20, 2025
9ae2b4e
fix github runner issues
samtholiya Sep 21, 2025
9d12809
use movefile function
samtholiya Sep 21, 2025
f77fc15
update tests
samtholiya Sep 21, 2025
d28b8e2
fix lint
samtholiya Sep 21, 2025
82bef63
fix ioutil depricated
samtholiya Sep 21, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,5 @@ internal/exec/output.*
# Coverage files
coverage.out
coverage.html
node_modules
tests.test
9 changes: 9 additions & 0 deletions cmd/markdown/atmos_toolchain_add.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
- Add a tool with version
```
$ atmos toolchain add <tool-name> <version>
```

- Use a custom tool versions file
```
$ atmos toolchain add --file <path/to/.tool-version> <tool-name> <version>
```
4 changes: 4 additions & 0 deletions cmd/markdown/atmos_toolchain_aliases.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- Get the aliases configured
```
$ atmos toolchain aliases
```
5 changes: 5 additions & 0 deletions cmd/markdown/atmos_toolchain_clean.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
- Delete everything from toolchain

```
$ atmos toolchain clean
```
9 changes: 9 additions & 0 deletions cmd/markdown/atmos_toolchain_exec.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
- Execute a command using the default tool
```
$ atmos toolchain exec <tool> <args>
```

- Execute a command using a specific tool version
```
$ atmos toolchain <tool>@<version> <args>
```
5 changes: 5 additions & 0 deletions cmd/markdown/atmos_toolchain_info.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
- Display tool info based on the aqua registry

```
$ atmos toolchain info <tool>
```
10 changes: 10 additions & 0 deletions cmd/markdown/atmos_toolchain_install.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

- Install all the tools added in tool-versions
```
$ atmos toolchain install
```

- Install a specifc version of a tool
```
$ atmos toolchain install <tool>@<verions>
```
4 changes: 4 additions & 0 deletions cmd/markdown/atmos_toolchain_list.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- Get the list of toolchain tools
```
$ atmos toolchain list
```
19 changes: 19 additions & 0 deletions cmd/markdown/atmos_toolchain_path.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
- Print PATH for all tools in .tool-versions (absolute paths)
```
$ atmos toolchain path
```

- Print the relative paths in the PATH
```
$ atmos toolchain path --relative
```

- Output the PATH for Shell scripting
```
$ atmos toolchain path --export
```

- Print PATH as JSON object
```
$ atmos toolchain path --json
```
9 changes: 9 additions & 0 deletions cmd/markdown/atmos_toolchain_remove.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
- Remove all versions of a tool
```
$ atmos toolchain remove terraform
```

- Remove a specific version of the tool
```
$ atmos toolchain remove <tool>@<version>
```
9 changes: 9 additions & 0 deletions cmd/markdown/atmos_toolchain_set.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
- Set a default version for the tool
```
$ atmos toolchain set <tool> 1.11.4
```

- Open the interactive UI to set tool versions
```
$ atmos toolchain set hashicorp/terraform
```
9 changes: 9 additions & 0 deletions cmd/markdown/atmos_toolchain_uninstall.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
- Uninstall a tool
```
$ atmos toolchain uninstall [email protected]
```

- Uninstall all the tools from .tool-versions
```
$ atmos toolchain uninstall
```
19 changes: 19 additions & 0 deletions cmd/markdown/atmos_toolchain_versions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
- Execute a toolchain version
```
$ atmos toolchain versions <tool>
```

- Execute a toolchain versions
```
$ atmos toolchain versions <tool> --file <path/to/tool-versions>
```

- Get all the versions of the tool
```
$ atmos toolchain versions <tool> --all
```

- Limit the number of versions returned for a tool
```
$ atmos toolchain versions <tool> --limit <number>
```
5 changes: 5 additions & 0 deletions cmd/markdown/atmos_toolchain_which.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
- Get the path of the tool

```
$ atmos toolchain which <tool>
```
5 changes: 4 additions & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"github.com/cloudposse/atmos/pkg/schema"
"github.com/cloudposse/atmos/pkg/telemetry"
"github.com/cloudposse/atmos/pkg/utils"
"github.com/cloudposse/atmos/toolchain"
)

// atmosConfig This is initialized before everything in the Execute function. So we can directly use this.
Expand Down Expand Up @@ -139,7 +140,7 @@ func Execute() error {
// Here we need the custom commands from the config
var initErr error
atmosConfig, initErr = cfg.InitCliConfig(schema.ConfigAndStacksInfo{}, false)

toolchain.SetAtmosConfig(&atmosConfig)
utils.InitializeMarkdown(atmosConfig)
errUtils.InitializeMarkdown(atmosConfig)

Expand Down Expand Up @@ -209,6 +210,8 @@ func init() {
RootCmd.PersistentFlags().StringSlice("config", []string{}, "Paths to configuration files (comma-separated or repeated flag)")
RootCmd.PersistentFlags().StringSlice("config-path", []string{}, "Paths to configuration directories (comma-separated or repeated flag)")
RootCmd.PersistentFlags().Bool("no-color", false, "Disable color output")

RootCmd.AddCommand(ToolChainCmd)
// Set custom usage template
err := templates.SetCustomUsageFunc(RootCmd)
if err != nil {
Expand Down
64 changes: 64 additions & 0 deletions cmd/toolchain.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package cmd

import (
"fmt"
"os"

"github.com/spf13/cobra"
"github.com/spf13/viper"
)

var (
githubToken string
toolVersionsFile string
toolsDir string
toolsConfigFile string
)

var ToolChainCmd = &cobra.Command{
Use: "toolchain",
Short: "Toolchain CLI",
Long: `A standalone tool to install CLI binaries using registry metadata.`,
PreRunE: func(cmd *cobra.Command, args []string) error {
// Set log level
return nil
},
}
Comment on lines +18 to +26
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Exported command needs a doc comment and PreRunE should initialize config.

Add a docstring and invoke toolchainInit using cliConfig from root.go.

-var ToolChainCmd = &cobra.Command{
+// ToolChainCmd is the root "toolchain" command for managing developer tooling versions and installs.
+var ToolChainCmd = &cobra.Command{
 	Use:   "toolchain",
 	Short: "Toolchain CLI",
 	Long:  `A standalone tool to install CLI binaries using registry metadata.`,
 	PreRunE: func(cmd *cobra.Command, args []string) error {
-		// Set log level
-		return nil
+		// Initialize toolchain config from flags/env before subcommands run.
+		toolchainInit(&cliConfig)
+		return nil
 	},
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
var ToolChainCmd = &cobra.Command{
Use: "toolchain",
Short: "Toolchain CLI",
Long: `A standalone tool to install CLI binaries using registry metadata.`,
PreRunE: func(cmd *cobra.Command, args []string) error {
// Set log level
return nil
},
}
// ToolChainCmd is the root "toolchain" command for managing developer tooling versions and installs.
var ToolChainCmd = &cobra.Command{
Use: "toolchain",
Short: "Toolchain CLI",
Long: `A standalone tool to install CLI binaries using registry metadata.`,
PreRunE: func(cmd *cobra.Command, args []string) error {
// Initialize toolchain config from flags/env before subcommands run.
toolchainInit(&cliConfig)
return nil
},
}
🤖 Prompt for AI Agents
In cmd/toolchain.go around lines 21 to 29, add a Go doc comment above the
exported ToolChainCmd variable describing the command purpose, and change the
PreRunE function to initialize configuration by calling toolchainInit with the
cliConfig defined in root.go; specifically, replace the no-op PreRunE with one
that calls toolchainInit(cliConfig) and returns any error it produces (so
initialization fails fast on error), ensuring cliConfig is referenced from the
same package (or imported if needed).


func init() {
// Add GitHub token flag and bind to environment variables
ToolChainCmd.PersistentFlags().StringVar(&githubToken, "github-token", "", "GitHub token for authenticated requests")
ToolChainCmd.PersistentFlags().MarkHidden("github-token") // Hide from help since it's primarily for env vars
// Bind environment variables with proper precedence (ATMOS_GITHUB_TOKEN takes precedence over GITHUB_TOKEN)
if err := viper.BindPFlag("github-token", ToolChainCmd.PersistentFlags().Lookup("github-token")); err != nil {
fmt.Fprintf(os.Stderr, "Error binding github-token flag: %v\n", err)
}
if err := viper.BindEnv("github-token", "ATMOS_GITHUB_TOKEN", "GITHUB_TOKEN"); err != nil {
fmt.Fprintf(os.Stderr, "Error binding github-token environment variables: %v\n", err)
Comment on lines +31 to +37
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Check MarkHidden error and de-duplicate "github-token" literal.

Also bind env with ATMOS_ taking precedence, as you did.

-	ToolChainCmd.PersistentFlags().StringVar(&githubToken, "github-token", "", "GitHub token for authenticated requests")
-	ToolChainCmd.PersistentFlags().MarkHidden("github-token") // Hide from help since it's primarily for env vars
+	ToolChainCmd.PersistentFlags().StringVar(&githubToken, flagGithubToken, "", "GitHub token for authenticated requests.")
+	if err := ToolChainCmd.PersistentFlags().MarkHidden(flagGithubToken); err != nil {
+		fmt.Fprintf(os.Stderr, "Error hiding %s flag: %v\n", flagGithubToken, err)
+	} // Hide from help since it's primarily for env vars.
 	// Bind environment variables with proper precedence (ATMOS_GITHUB_TOKEN takes precedence over GITHUB_TOKEN)
-	if err := viper.BindPFlag("github-token", ToolChainCmd.PersistentFlags().Lookup("github-token")); err != nil {
+	if err := viper.BindPFlag(flagGithubToken, ToolChainCmd.PersistentFlags().Lookup(flagGithubToken)); err != nil {
 		fmt.Fprintf(os.Stderr, "Error binding github-token flag: %v\n", err)
 	}
-	if err := viper.BindEnv("github-token", "ATMOS_GITHUB_TOKEN", "GITHUB_TOKEN"); err != nil {
+	if err := viper.BindEnv(flagGithubToken, "ATMOS_GITHUB_TOKEN", "GITHUB_TOKEN"); err != nil {
 		fmt.Fprintf(os.Stderr, "Error binding github-token environment variables: %v\n", err)
 	}

Committable suggestion skipped: line range outside the PR's diff.

🧰 Tools
🪛 GitHub Check: golangci-lint

[failure] 41-41:
Error return value of (*github.com/spf13/pflag.FlagSet).MarkHidden is not checked


[failure] 43-43:
add-constant: string literal "github-token" appears, at least, 4 times, create a named constant for it

🤖 Prompt for AI Agents
In cmd/toolchain.go around lines 41 to 47, avoid repeating the "github-token"
literal and handle the potential error from MarkHidden: introduce a single const
(e.g., githubTokenKey := "github-token") and use it for MarkHidden,
viper.BindPFlag and viper.BindEnv; capture and check the error returned by
ToolChainCmd.PersistentFlags().MarkHidden(githubTokenKey) and print to stderr on
failure, and keep the existing viper.BindEnv call ordering so ATMOS_GITHUB_TOKEN
takes precedence over GITHUB_TOKEN.

}

// Add tool-versions file flagd
ToolChainCmd.PersistentFlags().StringVar(&toolVersionsFile, "tool-versions", ".tool-versions", "Path to tool-versions file")

// Add tools directory flag
ToolChainCmd.PersistentFlags().StringVar(&toolsDir, "tools-dir", ".tools", "Directory to store installed tools")

// Add tools config file flag
ToolChainCmd.PersistentFlags().StringVar(&toolsConfigFile, "tools-config", "tools.yaml", "Path to tools configuration file")
}
Comment on lines +40 to +48
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Bind flags to viper and fix typo/punctuation in comments.

Provide env fallbacks per guidelines.

-	// Add tool-versions file flagd
-	ToolChainCmd.PersistentFlags().StringVar(&toolVersionsFile, "tool-versions", ".tool-versions", "Path to tool-versions file")
+	// Add tool-versions file flag.
+	ToolChainCmd.PersistentFlags().StringVar(&toolVersionsFile, flagToolVersions, ".tool-versions", "Path to the .tool-versions file.")
+	_ = viper.BindPFlag(flagToolVersions, ToolChainCmd.PersistentFlags().Lookup(flagToolVersions))
+	_ = viper.BindEnv(flagToolVersions, "ATMOS_TOOL_VERSIONS", "TOOL_VERSIONS")
 
-	// Add tools directory flag
-	ToolChainCmd.PersistentFlags().StringVar(&toolsDir, "tools-dir", ".tools", "Directory to store installed tools")
+	// Add tools directory flag.
+	ToolChainCmd.PersistentFlags().StringVar(&toolsDir, flagToolsDir, ".tools", "Directory to store installed tools.")
+	_ = viper.BindPFlag(flagToolsDir, ToolChainCmd.PersistentFlags().Lookup(flagToolsDir))
+	_ = viper.BindEnv(flagToolsDir, "ATMOS_TOOLS_DIR", "TOOLS_DIR")
 
-	// Add tools config file flag
-	ToolChainCmd.PersistentFlags().StringVar(&toolsConfigFile, "tools-config", "tools.yaml", "Path to tools configuration file")
+	// Add tools config file flag.
+	ToolChainCmd.PersistentFlags().StringVar(&toolsConfigFile, flagToolsConfig, "tools.yaml", "Path to tools configuration file.")
+	_ = viper.BindPFlag(flagToolsConfig, ToolChainCmd.PersistentFlags().Lookup(flagToolsConfig))
+	_ = viper.BindEnv(flagToolsConfig, "ATMOS_TOOLS_CONFIG", "TOOLS_CONFIG")
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// Add tool-versions file flagd
ToolChainCmd.PersistentFlags().StringVar(&toolVersionsFile, "tool-versions", ".tool-versions", "Path to tool-versions file")
// Add tools directory flag
ToolChainCmd.PersistentFlags().StringVar(&toolsDir, "tools-dir", ".tools", "Directory to store installed tools")
// Add tools config file flag
ToolChainCmd.PersistentFlags().StringVar(&toolsConfigFile, "tools-config", "tools.yaml", "Path to tools configuration file")
}
// Add tool-versions file flag.
ToolChainCmd.PersistentFlags().StringVar(&toolVersionsFile, flagToolVersions, ".tool-versions", "Path to the .tool-versions file.")
_ = viper.BindPFlag(flagToolVersions, ToolChainCmd.PersistentFlags().Lookup(flagToolVersions))
_ = viper.BindEnv(flagToolVersions, "ATMOS_TOOL_VERSIONS", "TOOL_VERSIONS")
// Add tools directory flag.
ToolChainCmd.PersistentFlags().StringVar(&toolsDir, flagToolsDir, ".tools", "Directory to store installed tools.")
_ = viper.BindPFlag(flagToolsDir, ToolChainCmd.PersistentFlags().Lookup(flagToolsDir))
_ = viper.BindEnv(flagToolsDir, "ATMOS_TOOLS_DIR", "TOOLS_DIR")
// Add tools config file flag.
ToolChainCmd.PersistentFlags().StringVar(&toolsConfigFile, flagToolsConfig, "tools.yaml", "Path to tools configuration file.")
_ = viper.BindPFlag(flagToolsConfig, ToolChainCmd.PersistentFlags().Lookup(flagToolsConfig))
_ = viper.BindEnv(flagToolsConfig, "ATMOS_TOOLS_CONFIG", "TOOLS_CONFIG")
}
🤖 Prompt for AI Agents
In cmd/toolchain.go around lines 50 to 58, the flag comments contain a typo
("flagd") and inconsistent punctuation, and the flags are not bound to viper or
environment fallbacks; update the comments to fix the typo and punctuation
(e.g., "Add tool-versions file flag", "Add tools directory flag", "Add tools
config file flag"), then bind each persistent flag to viper using
viper.BindPFlag for "tool-versions", "tools-dir", and "tools-config", and also
register environment fallbacks with viper.BindEnv using sensible env var names
(e.g., TOOL_VERSIONS, TOOLS_DIR, TOOLS_CONFIG) so values can come from flags,
config, or environment.


func init() {
ToolChainCmd.AddCommand(toolchainAddCmd)
ToolChainCmd.AddCommand(toolchainRemoveCmd)
ToolChainCmd.AddCommand(toolchainSetCmd)
ToolChainCmd.AddCommand(toolchainVersionsCmd)
ToolChainCmd.AddCommand(toolchainCleanCmd)
ToolChainCmd.AddCommand(toolchainExecCmd)
ToolChainCmd.AddCommand(toolchainListCmd)
ToolChainCmd.AddCommand(toolchainInstallCmd)
ToolChainCmd.AddCommand(toolchainUninstallCmd)
ToolChainCmd.AddCommand(toolchainPathCmd)
ToolChainCmd.AddCommand(toolchainInfoCmd)
ToolChainCmd.AddCommand(toolchainAliasesCmd)
ToolChainCmd.AddCommand(toolchainWhichCmd)
}
40 changes: 40 additions & 0 deletions cmd/toolchain_add.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package cmd

import (
"github.com/cloudposse/atmos/toolchain"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)

var toolchainAddCmd = &cobra.Command{
Use: "add <tool> <version>",
Short: "Add or update a tool and version in .tool-versions",
Long: `Add or update a tool and version in the .tool-versions file.

This command adds a tool and its version to the .tool-versions file. If the tool
already exists, it will be updated with the new version.

The tool will be validated against the registry to ensure it exists before being added.
`,
Args: cobra.ExactArgs(2),
RunE: runAddToolCmd,
}

func runAddToolCmd(cmd *cobra.Command, args []string) error {
filePath, _ := cmd.Flags().GetString("file")
if filePath != "" {
atmosConfig.Toolchain.FilePath = filePath
}
tool := args[0]
version := args[1]
// Call the business logic
if err := toolchain.AddToolVersion(tool, version); err != nil {
return err
}
return nil
}

func init() {
toolchainAddCmd.Flags().String("file", "", "Path to tool-versions file (defaults to global --tool-versions-file)")
_ = viper.BindEnv("toolchain.file_path", "TOOLCHAIN_PATH_RELATIVE", "ATMOS_TOOLCHAIN_PATH_RELATIVE")
}
19 changes: 19 additions & 0 deletions cmd/toolchain_aliases.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package cmd

import (
"github.com/cloudposse/atmos/toolchain"
"github.com/spf13/cobra"
)

// toolchainAliasesCmd defines the Cobra command for listing aliases.
var toolchainAliasesCmd = &cobra.Command{
Use: "aliases",
Short: "List configured tool aliases",
Long: `List all configured tool aliases from the local tools.yaml configuration.

Aliases allow you to use short tool names (like 'terraform') instead of
full owner/repo paths (like 'hashicorp/terraform') in commands.`,
RunE: func(cmd *cobra.Command, args []string) error {
return toolchain.ListAliases()
},
}
31 changes: 31 additions & 0 deletions cmd/toolchain_clean.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package cmd

import (
"os"
"path/filepath"

"github.com/cloudposse/atmos/toolchain"
"github.com/spf13/cobra"
)

var toolchainCleanCmd = &cobra.Command{
Use: "clean",
Short: "Remove all installed tools by deleting the .tools directory",
Long: `Remove all installed tools by deleting the .tools directory.

This command will:
- Count the number of files/directories in the .tools directory
- Delete the entire .tools directory and all its contents
- Display a summary of what was deleted

Use this command to completely clean up all installed tools.`,
RunE: func(cmd *cobra.Command, args []string) error {
toolsDir := atmosConfig.Toolchain.ToolsDir

homeDir, _ := os.UserHomeDir()
cacheDir := filepath.Join(homeDir, ".cache", "tools-cache")
tempCacheDir := filepath.Join(os.TempDir(), "tools-cache")

return toolchain.CleanToolsAndCaches(toolsDir, cacheDir, tempCacheDir)
},
}
21 changes: 21 additions & 0 deletions cmd/toolchain_exec.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package cmd

import (
"github.com/cloudposse/atmos/toolchain"
"github.com/spf13/cobra"
)

var toolchainExecCmd = &cobra.Command{
Use: "exec [tool[@version]] [flags...]",
Short: "Exec a specific version of a tool (replaces current process)",
Long: `Exec a specific version of a tool with arguments, replacing the current process.

If no version is specified, the latest version will be used.
`,
Args: cobra.MinimumNArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
installer := toolchain.NewInstaller()
return toolchain.RunExecCommand(installer, args)
},
DisableFlagParsing: true,
}
31 changes: 31 additions & 0 deletions cmd/toolchain_get.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package cmd

import (
"github.com/cloudposse/atmos/toolchain"
"github.com/spf13/cobra"
)

const defaultVersionsLimit = 50

var toolchainVersionsCmd = &cobra.Command{
Use: "versions <tool>",
Short: "List available or configured versions for a tool",
Args: cobra.ExactArgs(1), // Requires exactly one argument (tool name)
RunE: func(cmd *cobra.Command, args []string) error {
filePath, _ := cmd.Flags().GetString("file")
showAll, _ := cmd.Flags().GetBool("all")
limit, _ := cmd.Flags().GetInt("limit")
toolName := args[0]
if filePath != "" {
atmosConfig.Toolchain.FilePath = filePath
}
toolchain.SetAtmosConfig(&atmosConfig)
return toolchain.ListToolVersions(showAll, limit, toolName)
},
}

func init() {
toolchainVersionsCmd.Flags().String("file", "", "Path to tool-versions file (defaults to global --tool-versions-file)")
toolchainVersionsCmd.Flags().Bool("all", false, "Fetch all available versions from GitHub API")
toolchainVersionsCmd.Flags().Int("limit", defaultVersionsLimit, "Maximum number of versions to fetch when using --all")
}
Loading