Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 5 additions & 0 deletions .changes/v1.14/ENHANCEMENTS-20250919-115253.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
kind: ENHANCEMENTS
body: '`terraform stacks` command support for `-help` flag'
time: 2025-09-19T11:52:53.923764-04:00
custom:
Issue: "37645"
14 changes: 11 additions & 3 deletions internal/command/stacks.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ func (c *StacksCommand) realRun(args []string, stdout, stderr io.Writer) int {
args = c.Meta.process(args)
cmdFlags := c.Meta.defaultFlagSet("stacks")
cmdFlags.StringVar(&pluginCacheDirOverride, "plugin-cache-dir", "", "plugin cache directory")
cmdFlags.Usage = func() { c.Ui.Error(c.Help()) }
cmdFlags.Parse(args)

if pluginCacheDirOverride != "" {
Expand Down Expand Up @@ -379,8 +378,17 @@ func (c *StacksCommand) Run(args []string) int {
// Help returns help text for the stacks command.
func (c *StacksCommand) Help() string {
helpText := new(bytes.Buffer)
if exitCode := c.realRun([]string{}, helpText, io.Discard); exitCode != 0 {
return ""
errorText := new(bytes.Buffer)

parsedArgs := []string{}
for _, arg := range os.Args[1:] {
if arg == "stacks" {
continue // skip stacks command name
}
parsedArgs = append(parsedArgs, arg)
}
if exitCode := c.realRun(parsedArgs, helpText, errorText); exitCode != 0 {
return errorText.String()
}

return helpText.String()
Expand Down