diff --git a/command/build.go b/command/build.go index b5ae3bd66..bf5d72aee 100644 --- a/command/build.go +++ b/command/build.go @@ -13,6 +13,8 @@ import ( "github.com/hashicorp/packer/helper/enumflag" "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/template" + + "github.com/posener/complete" ) type BuildCommand struct { @@ -306,3 +308,22 @@ Options: func (*BuildCommand) Synopsis() string { return "build image(s) from template" } + +func (*BuildCommand) AutocompleteArgs() complete.Predictor { + return complete.PredictNothing +} + +func (*BuildCommand) AutocompleteFlags() complete.Flags { + return complete.Flags{ + "-color": complete.PredictNothing, + "-debug": complete.PredictNothing, + "-except": complete.PredictNothing, + "-only": complete.PredictNothing, + "-force": complete.PredictNothing, + "-machine-readable": complete.PredictNothing, + "-on-error": complete.PredictNothing, + "-parallel": complete.PredictNothing, + "-var": complete.PredictNothing, + "-var-file": complete.PredictNothing, + } +} diff --git a/command/fix.go b/command/fix.go index 1a94f5786..49142d379 100644 --- a/command/fix.go +++ b/command/fix.go @@ -10,6 +10,8 @@ import ( "github.com/hashicorp/packer/fix" "github.com/hashicorp/packer/template" + + "github.com/posener/complete" ) type FixCommand struct { @@ -140,3 +142,13 @@ Options: func (c *FixCommand) Synopsis() string { return "fixes templates from old versions of packer" } + +func (c *FixCommand) AutocompleteArgs() complete.Predictor { + return complete.PredictNothing +} + +func (c *FixCommand) AutocompleteFlags() complete.Flags { + return complete.Flags{ + "-validate": complete.PredictNothing, + } +} diff --git a/command/inspect.go b/command/inspect.go index 71ddbba1d..f71efcf20 100644 --- a/command/inspect.go +++ b/command/inspect.go @@ -6,6 +6,8 @@ import ( "strings" "github.com/hashicorp/packer/template" + + "github.com/posener/complete" ) type InspectCommand struct { @@ -160,3 +162,13 @@ Options: func (c *InspectCommand) Synopsis() string { return "see components of a template" } + +func (c *InspectCommand) AutocompleteArgs() complete.Predictor { + return complete.PredictNothing +} + +func (c *InspectCommand) AutocompleteFlags() complete.Flags { + return complete.Flags{ + "-machine-readable": complete.PredictNothing, + } +} diff --git a/command/push.go b/command/push.go index e1d6c7db2..586b7729b 100644 --- a/command/push.go +++ b/command/push.go @@ -14,6 +14,8 @@ import ( "github.com/hashicorp/packer/helper/flag-kv" "github.com/hashicorp/packer/helper/flag-slice" "github.com/hashicorp/packer/template" + + "github.com/posener/complete" ) // archiveTemplateEntry is the name the template always takes within the slug. @@ -324,6 +326,20 @@ func (*PushCommand) Synopsis() string { return "push a template and supporting files to a Packer build service" } +func (*PushCommand) AutocompleteArgs() complete.Predictor { + return complete.PredictNothing +} + +func (*PushCommand) AutocompleteFlags() complete.Flags { + return complete.Flags{ + "-name": complete.PredictNothing, + "-token": complete.PredictNothing, + "-sensitive": complete.PredictNothing, + "-var": complete.PredictNothing, + "-var-file": complete.PredictNothing, + } +} + func (c *PushCommand) upload( r *archive.Archive, opts *uploadOpts) (<-chan struct{}, <-chan error, error) { if c.uploadFn != nil { diff --git a/command/validate.go b/command/validate.go index a2fb47ff6..05c29dc2c 100644 --- a/command/validate.go +++ b/command/validate.go @@ -7,6 +7,8 @@ import ( "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/template" + + "github.com/posener/complete" ) type ValidateCommand struct { @@ -136,3 +138,17 @@ Options: func (*ValidateCommand) Synopsis() string { return "check that a template is valid" } + +func (*ValidateCommand) AutocompleteArgs() complete.Predictor { + return complete.PredictNothing +} + +func (*ValidateCommand) AutocompleteFlags() complete.Flags { + return complete.Flags{ + "-syntax-only": complete.PredictNothing, + "-except": complete.PredictNothing, + "-only": complete.PredictNothing, + "-var": complete.PredictNothing, + "-var-file": complete.PredictNothing, + } +}