-
-
Notifications
You must be signed in to change notification settings - Fork 133
Support Atmos Toolchain for 3rd Party Tools #1466
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
929ff3f
3cef77b
8377c82
5684420
dc108c5
00fcc37
ede6dbd
08bb8e2
ef9e072
c85671a
7228903
a5f0bde
06fb8b6
b32c16a
0dfb620
f6d6fa6
f0c5c42
429e311
813da01
9678326
46e7776
3641f28
93cba98
2032866
9536b16
d3878a3
00b5724
7b2ee9d
2271fea
cfc9a64
b88cd0b
bc0d937
18fc85f
df22df1
0afbd37
b2ed865
784162f
785f7fd
f21bc6c
21e008b
121f12b
bb4fb0e
ba3b5e6
a23abb4
bbcbc3a
85e4392
bb7e62f
6336466
94e0a56
2a5d08d
bef2ef5
859c1f1
f8079eb
c9cd2b3
c7badf1
a3cbba5
f97d048
1bce6de
df0ad9c
248a452
3c0f957
c4434d2
cabceb4
0cca05f
8a1bcb9
2c04234
c20d17e
2af6936
aa02ad2
3d86485
53b5836
1ec5454
ebafb50
1c10323
32f6404
8db7731
7871d64
9dfe495
48adbc0
9a52373
91214a5
a7bc3ca
480e43b
672fd20
9ae2b4e
9d12809
f77fc15
d28b8e2
82bef63
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,4 +51,5 @@ internal/exec/output.* | |
# Coverage files | ||
coverage.out | ||
coverage.html | ||
node_modules | ||
tests.test |
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> | ||
``` | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
- Get the aliases configured | ||
``` | ||
$ atmos toolchain aliases | ||
``` | ||
samtholiya marked this conversation as resolved.
Show resolved
Hide resolved
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
- Delete everything from toolchain | ||
|
||
``` | ||
$ atmos toolchain clean | ||
``` | ||
samtholiya marked this conversation as resolved.
Show resolved
Hide resolved
|
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> | ||
``` | ||
samtholiya marked this conversation as resolved.
Show resolved
Hide resolved
|
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> | ||
``` | ||
samtholiya marked this conversation as resolved.
Show resolved
Hide resolved
|
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> | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
- Get the list of toolchain tools | ||
``` | ||
$ atmos toolchain list | ||
``` |
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 | ||
``` |
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> | ||
``` |
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 | ||
``` | ||
samtholiya marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
- Open the interactive UI to set tool versions | ||
``` | ||
$ atmos toolchain set hashicorp/terraform | ||
``` |
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 | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
- Execute a toolchain version | ||
samtholiya marked this conversation as resolved.
Show resolved
Hide resolved
|
||
``` | ||
$ atmos toolchain versions <tool> | ||
``` | ||
samtholiya marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
- 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> | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
- Get the path of the tool | ||
|
||
``` | ||
$ atmos toolchain which <tool> | ||
``` | ||
samtholiya marked this conversation as resolved.
Show resolved
Hide resolved
|
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
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Suggested change
🤖 Prompt for AI Agents
|
||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||
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
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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)
}
🧰 Tools🪛 GitHub Check: golangci-lint[failure] 41-41: [failure] 43-43: 🤖 Prompt for AI Agents
|
||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||
// 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
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Suggested change
🤖 Prompt for AI Agents
|
||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||
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) | ||||||||||||||||||||||||||||||||||||||||||||||||||
} |
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") | ||
} |
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() | ||
}, | ||
} |
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) | ||
}, | ||
} |
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, | ||
} |
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") | ||
} |
Uh oh!
There was an error while loading. Please reload this page.