diff --git a/command/plan.go b/command/plan.go index f86bd9dca..83d494ed6 100644 --- a/command/plan.go +++ b/command/plan.go @@ -9,6 +9,7 @@ import ( "github.com/hashicorp/nomad/api" "github.com/hashicorp/nomad/scheduler" "github.com/mitchellh/colorstring" + "github.com/posener/complete" ) const ( @@ -77,6 +78,14 @@ func (c *PlanCommand) Synopsis() string { return "Dry-run a job update to determine its effects" } +func (c *PlanCommand) AutocompleteFlags() complete.Flags { + return nil +} + +func (c *PlanCommand) AutocompleteArgs() complete.Predictor { + return complete.PredictOr(complete.PredictFiles("*.nomad"), complete.PredictFiles("*.hcl")) +} + func (c *PlanCommand) Run(args []string) int { var diff, verbose bool diff --git a/command/run.go b/command/run.go index d6aad1729..a386def27 100644 --- a/command/run.go +++ b/command/run.go @@ -14,6 +14,7 @@ import ( "github.com/hashicorp/nomad/api" "github.com/hashicorp/nomad/helper" "github.com/hashicorp/nomad/nomad/structs" + "github.com/posener/complete" ) var ( @@ -96,6 +97,14 @@ func (c *RunCommand) Synopsis() string { return "Run a new job or update an existing job" } +func (c *RunCommand) AutocompleteFlags() complete.Flags { + return nil +} + +func (c *RunCommand) AutocompleteArgs() complete.Predictor { + return complete.PredictOr(complete.PredictFiles("*.nomad"), complete.PredictFiles("*.hcl")) +} + func (c *RunCommand) Run(args []string) int { var detach, verbose, output bool var checkIndexStr, vaultToken string diff --git a/command/validate.go b/command/validate.go index 6bbdda396..1dff70da9 100644 --- a/command/validate.go +++ b/command/validate.go @@ -8,6 +8,7 @@ import ( "github.com/hashicorp/nomad/api" "github.com/hashicorp/nomad/command/agent" "github.com/hashicorp/nomad/nomad/structs" + "github.com/posener/complete" ) type ValidateCommand struct { @@ -33,6 +34,14 @@ func (c *ValidateCommand) Synopsis() string { return "Checks if a given job specification is valid" } +func (c *ValidateCommand) AutocompleteFlags() complete.Flags { + return nil +} + +func (c *ValidateCommand) AutocompleteArgs() complete.Predictor { + return complete.PredictOr(complete.PredictFiles("*.nomad"), complete.PredictFiles("*.hcl")) +} + func (c *ValidateCommand) Run(args []string) int { flags := c.Meta.FlagSet("validate", FlagSetNone) flags.Usage = func() { c.Ui.Output(c.Help()) }