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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# 📦 Changelog

## 1.16.3 (Unreleased)

### BUG FIXES:

* command: restore file and directory completion for commands that accept paths

## 1.16.2 (October 22, 2026)

### BUG FIXES:
Expand Down
2 changes: 1 addition & 1 deletion command/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ func (*BuildCommand) Synopsis() string {
}

func (*BuildCommand) AutocompleteArgs() complete.Predictor {
return complete.PredictNothing
return complete.PredictFiles("*")
}

func (*BuildCommand) AutocompleteFlags() complete.Flags {
Expand Down
27 changes: 27 additions & 0 deletions command/command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,37 @@ import (

packersdk "github.com/hashicorp/packer-plugin-sdk/packer"
"github.com/hashicorp/packer/packer"
"github.com/posener/complete"
"github.com/stretchr/testify/require"
)

const fixturesDir = "./test-fixtures"

func TestAutocompleteArgs(t *testing.T) {
t.Chdir(t.TempDir())
require.NoError(t, os.WriteFile("template.pkr.hcl", nil, 0600))
require.NoError(t, os.WriteFile("template.json", nil, 0600))
require.NoError(t, os.Mkdir("templates", 0700))

for name, predictor := range map[string]complete.Predictor{
"build": (&BuildCommand{}).AutocompleteArgs(),
"console": (&ConsoleCommand{}).AutocompleteArgs(),
"fix": (&FixCommand{}).AutocompleteArgs(),
"fmt": (&FormatCommand{}).AutocompleteArgs(),
"hcl2_upgrade": (&HCL2UpgradeCommand{}).AutocompleteArgs(),
"init": (&InitCommand{}).AutocompleteArgs(),
"inspect": (&InspectCommand{}).AutocompleteArgs(),
"validate": (&ValidateCommand{}).AutocompleteArgs(),
"verify-attestation": (&VerifyAttestationCommand{}).AutocompleteArgs(),
} {
t.Run(name, func(t *testing.T) {
require.NotNil(t, predictor)
got := predictor.Predict(complete.Args{Last: "templ"})
require.ElementsMatch(t, []string{"template.pkr.hcl", "template.json", "templates/"}, got)
})
}
}

func fatalCommand(t *testing.T, m Meta) {
ui := m.Ui.(*packersdk.BasicUi)
out := ui.Writer.(*bytes.Buffer)
Expand Down
2 changes: 1 addition & 1 deletion command/console.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func (*ConsoleCommand) Synopsis() string {
}

func (*ConsoleCommand) AutocompleteArgs() complete.Predictor {
return complete.PredictNothing
return complete.PredictFiles("*")
}

func (*ConsoleCommand) AutocompleteFlags() complete.Flags {
Expand Down
2 changes: 1 addition & 1 deletion command/fix.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ func (c *FixCommand) Synopsis() string {
}

func (c *FixCommand) AutocompleteArgs() complete.Predictor {
return complete.PredictNothing
return complete.PredictFiles("*")
}

func (c *FixCommand) AutocompleteFlags() complete.Flags {
Expand Down
2 changes: 1 addition & 1 deletion command/fmt.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ func (*FormatCommand) Synopsis() string {
}

func (*FormatCommand) AutocompleteArgs() complete.Predictor {
return complete.PredictNothing
return complete.PredictFiles("*")
}

func (*FormatCommand) AutocompleteFlags() complete.Flags {
Expand Down
2 changes: 1 addition & 1 deletion command/hcl2_upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -803,7 +803,7 @@ func (*HCL2UpgradeCommand) Synopsis() string {
}

func (*HCL2UpgradeCommand) AutocompleteArgs() complete.Predictor {
return complete.PredictNothing
return complete.PredictFiles("*")
}

func (*HCL2UpgradeCommand) AutocompleteFlags() complete.Flags {
Expand Down
2 changes: 1 addition & 1 deletion command/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ func (*InitCommand) Synopsis() string {
}

func (*InitCommand) AutocompleteArgs() complete.Predictor {
return complete.PredictNothing
return complete.PredictFiles("*")
}

func (*InitCommand) AutocompleteFlags() complete.Flags {
Expand Down
2 changes: 1 addition & 1 deletion command/inspect.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func (c *InspectCommand) Synopsis() string {
}

func (c *InspectCommand) AutocompleteArgs() complete.Predictor {
return complete.PredictNothing
return complete.PredictFiles("*")
}

func (c *InspectCommand) AutocompleteFlags() complete.Flags {
Expand Down
2 changes: 1 addition & 1 deletion command/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ func (*ValidateCommand) Synopsis() string {
}

func (*ValidateCommand) AutocompleteArgs() complete.Predictor {
return complete.PredictNothing
return complete.PredictFiles("*")
}

func (*ValidateCommand) AutocompleteFlags() complete.Flags {
Expand Down
2 changes: 1 addition & 1 deletion command/verify_attestation.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ func (*VerifyAttestationCommand) Synopsis() string {
}

func (*VerifyAttestationCommand) AutocompleteArgs() complete.Predictor {
return complete.PredictNothing
return complete.PredictFiles("*")
}

func (*VerifyAttestationCommand) AutocompleteFlags() complete.Flags {
Expand Down
Loading