mirror of
https://github.com/kemko/nomad.git
synced 2026-01-06 18:35:44 +03:00
Autocomplete deployment commands
This commit is contained in:
@@ -3,6 +3,9 @@ package command
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/hashicorp/nomad/api/contexts"
|
||||
"github.com/posener/complete"
|
||||
)
|
||||
|
||||
type DeploymentPauseCommand struct {
|
||||
@@ -32,6 +35,25 @@ func (c *DeploymentPauseCommand) Synopsis() string {
|
||||
return "Pause a deployment"
|
||||
}
|
||||
|
||||
func (c *DeploymentPauseCommand) AutocompleteFlags() complete.Flags {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *DeploymentPauseCommand) AutocompleteArgs() complete.Predictor {
|
||||
client, _ := c.Meta.Client()
|
||||
return complete.PredictFunc(func(a complete.Args) []string {
|
||||
if len(a.Completed) > 1 {
|
||||
return nil
|
||||
}
|
||||
|
||||
resp, err := client.Search().PrefixSearch(a.Last, contexts.Deployments)
|
||||
if err != nil {
|
||||
return []string{}
|
||||
}
|
||||
return resp.Matches[contexts.Deployments]
|
||||
})
|
||||
}
|
||||
|
||||
func (c *DeploymentPauseCommand) Run(args []string) int {
|
||||
var verbose bool
|
||||
|
||||
|
||||
Reference in New Issue
Block a user