Implement cli.CommandAutocomplete for most commands
This commit is contained in:
parent
a4cb8ae41b
commit
bfc75eb9d9
@ -13,6 +13,8 @@ import (
|
|||||||
"github.com/hashicorp/packer/helper/enumflag"
|
"github.com/hashicorp/packer/helper/enumflag"
|
||||||
"github.com/hashicorp/packer/packer"
|
"github.com/hashicorp/packer/packer"
|
||||||
"github.com/hashicorp/packer/template"
|
"github.com/hashicorp/packer/template"
|
||||||
|
|
||||||
|
"github.com/posener/complete"
|
||||||
)
|
)
|
||||||
|
|
||||||
type BuildCommand struct {
|
type BuildCommand struct {
|
||||||
@ -306,3 +308,22 @@ Options:
|
|||||||
func (*BuildCommand) Synopsis() string {
|
func (*BuildCommand) Synopsis() string {
|
||||||
return "build image(s) from template"
|
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,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -10,6 +10,8 @@ import (
|
|||||||
|
|
||||||
"github.com/hashicorp/packer/fix"
|
"github.com/hashicorp/packer/fix"
|
||||||
"github.com/hashicorp/packer/template"
|
"github.com/hashicorp/packer/template"
|
||||||
|
|
||||||
|
"github.com/posener/complete"
|
||||||
)
|
)
|
||||||
|
|
||||||
type FixCommand struct {
|
type FixCommand struct {
|
||||||
@ -140,3 +142,13 @@ Options:
|
|||||||
func (c *FixCommand) Synopsis() string {
|
func (c *FixCommand) Synopsis() string {
|
||||||
return "fixes templates from old versions of packer"
|
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,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -6,6 +6,8 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/hashicorp/packer/template"
|
"github.com/hashicorp/packer/template"
|
||||||
|
|
||||||
|
"github.com/posener/complete"
|
||||||
)
|
)
|
||||||
|
|
||||||
type InspectCommand struct {
|
type InspectCommand struct {
|
||||||
@ -160,3 +162,13 @@ Options:
|
|||||||
func (c *InspectCommand) Synopsis() string {
|
func (c *InspectCommand) Synopsis() string {
|
||||||
return "see components of a template"
|
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,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -14,6 +14,8 @@ import (
|
|||||||
"github.com/hashicorp/packer/helper/flag-kv"
|
"github.com/hashicorp/packer/helper/flag-kv"
|
||||||
"github.com/hashicorp/packer/helper/flag-slice"
|
"github.com/hashicorp/packer/helper/flag-slice"
|
||||||
"github.com/hashicorp/packer/template"
|
"github.com/hashicorp/packer/template"
|
||||||
|
|
||||||
|
"github.com/posener/complete"
|
||||||
)
|
)
|
||||||
|
|
||||||
// archiveTemplateEntry is the name the template always takes within the slug.
|
// 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"
|
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(
|
func (c *PushCommand) upload(
|
||||||
r *archive.Archive, opts *uploadOpts) (<-chan struct{}, <-chan error, error) {
|
r *archive.Archive, opts *uploadOpts) (<-chan struct{}, <-chan error, error) {
|
||||||
if c.uploadFn != nil {
|
if c.uploadFn != nil {
|
||||||
|
@ -7,6 +7,8 @@ import (
|
|||||||
|
|
||||||
"github.com/hashicorp/packer/packer"
|
"github.com/hashicorp/packer/packer"
|
||||||
"github.com/hashicorp/packer/template"
|
"github.com/hashicorp/packer/template"
|
||||||
|
|
||||||
|
"github.com/posener/complete"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ValidateCommand struct {
|
type ValidateCommand struct {
|
||||||
@ -136,3 +138,17 @@ Options:
|
|||||||
func (*ValidateCommand) Synopsis() string {
|
func (*ValidateCommand) Synopsis() string {
|
||||||
return "check that a template is valid"
|
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,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user