Merge pull request #2855 from hashicorp/f-autocomplete-files

Autocomplete files
This commit is contained in:
Alex Dadgar
2017-07-18 14:10:36 -07:00
committed by GitHub
3 changed files with 27 additions and 0 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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()) }