diff --git a/command/alloc_status.go b/command/alloc_status.go index 6835375e0..9108590cf 100644 --- a/command/alloc_status.go +++ b/command/alloc_status.go @@ -61,7 +61,12 @@ func (c *AllocStatusCommand) Synopsis() string { } func (c *AllocStatusCommand) AutocompleteFlags() complete.Flags { - return nil + return complete.Flags{ + "-short": complete.PredictNothing, + "-verbose": complete.PredictNothing, + "-json": complete.PredictNothing, + "-t": complete.PredictNothing, + } } func (c *AllocStatusCommand) AutocompleteArgs() complete.Predictor { diff --git a/command/check.go b/command/check.go index c37bf858a..ab57b6908 100644 --- a/command/check.go +++ b/command/check.go @@ -5,6 +5,8 @@ import ( "strconv" "strings" "time" + + "github.com/posener/complete" ) const ( @@ -127,3 +129,14 @@ func (c *AgentCheckCommand) checkClientHealth(clientStats map[string]string, min return HealthPass } + +func (c *AgentCheckCommand) AutocompleteFlags() complete.Flags { + return complete.Flags{ + "-min-peers": complete.PredictNothing, + "-min-servers": complete.PredictNothing, + } +} + +func (c *AgentCheckCommand) AutocompleteArgs() complete.Predictor { + return complete.PredictNothing +} diff --git a/command/client_config.go b/command/client_config.go index d370ebb3e..6f2b082c5 100644 --- a/command/client_config.go +++ b/command/client_config.go @@ -3,6 +3,8 @@ package command import ( "fmt" "strings" + + "github.com/posener/complete" ) type ClientConfigCommand struct { @@ -108,3 +110,14 @@ func (c *ClientConfigCommand) Run(args []string) int { // Should not make it this far return 1 } + +func (c *ClientConfigCommand) AutocompleteFlags() complete.Flags { + return complete.Flags{ + "-servers": complete.PredictNothing, + "-update-servers": complete.PredictNothing, + } +} + +func (c *ClientConfigCommand) AutocompleteArgs() complete.Predictor { + return complete.PredictNothing +} diff --git a/command/deployment_fail.go b/command/deployment_fail.go index ae99e9193..8d357e3ba 100644 --- a/command/deployment_fail.go +++ b/command/deployment_fail.go @@ -43,7 +43,10 @@ func (c *DeploymentFailCommand) Synopsis() string { } func (c *DeploymentFailCommand) AutocompleteFlags() complete.Flags { - return nil + return complete.Flags{ + "-detach": complete.PredictNothing, + "-verbose": complete.PredictNothing, + } } func (c *DeploymentFailCommand) AutocompleteArgs() complete.Predictor { diff --git a/command/deployment_list.go b/command/deployment_list.go index 924ab5fd2..c997d95c2 100644 --- a/command/deployment_list.go +++ b/command/deployment_list.go @@ -5,6 +5,7 @@ import ( "strings" "github.com/hashicorp/nomad/api" + "github.com/posener/complete" ) type DeploymentListCommand struct { @@ -35,6 +36,18 @@ List Options: return strings.TrimSpace(helpText) } +func (c *DeploymentListCommand) AutocompleteFlags() complete.Flags { + return complete.Flags{ + "-json": complete.PredictNothing, + "-t": complete.PredictNothing, + "-verbose": complete.PredictNothing, + } +} + +func (c *DeploymentListCommand) AutocompleteArgs() complete.Predictor { + return complete.PredictNothing +} + func (c *DeploymentListCommand) Synopsis() string { return "List all deployments" } diff --git a/command/deployment_pause.go b/command/deployment_pause.go index e0b824863..fa996431c 100644 --- a/command/deployment_pause.go +++ b/command/deployment_pause.go @@ -32,11 +32,13 @@ Pause Options: } func (c *DeploymentPauseCommand) Synopsis() string { - return "Pause a deployment" + return "Pause a deployment." } func (c *DeploymentPauseCommand) AutocompleteFlags() complete.Flags { - return nil + return complete.Flags{ + "-verbose": complete.PredictNothing, + } } func (c *DeploymentPauseCommand) AutocompleteArgs() complete.Predictor { diff --git a/command/deployment_promote.go b/command/deployment_promote.go index 603ecad2d..0a7003cba 100644 --- a/command/deployment_promote.go +++ b/command/deployment_promote.go @@ -48,11 +48,15 @@ Promote Options: } func (c *DeploymentPromoteCommand) Synopsis() string { - return "Promote canaries in a deployment" + return "Promote canaries in a deployment." } func (c *DeploymentPromoteCommand) AutocompleteFlags() complete.Flags { - return nil + return complete.Flags{ + "-group": complete.PredictNothing, + "-detach": complete.PredictNothing, + "-verbose": complete.PredictNothing, + } } func (c *DeploymentPromoteCommand) AutocompleteArgs() complete.Predictor { diff --git a/command/deployment_resume.go b/command/deployment_resume.go index 5e0ebadac..eaf58a90c 100644 --- a/command/deployment_resume.go +++ b/command/deployment_resume.go @@ -41,7 +41,10 @@ func (c *DeploymentResumeCommand) Synopsis() string { } func (c *DeploymentResumeCommand) AutocompleteFlags() complete.Flags { - return nil + return complete.Flags{ + "-detach": complete.PredictNothing, + "-verbose": complete.PredictNothing, + } } func (c *DeploymentResumeCommand) AutocompleteArgs() complete.Predictor { diff --git a/command/deployment_status.go b/command/deployment_status.go index 513f6e178..0ef8db54f 100644 --- a/command/deployment_status.go +++ b/command/deployment_status.go @@ -43,7 +43,11 @@ func (c *DeploymentStatusCommand) Synopsis() string { } func (c *DeploymentStatusCommand) AutocompleteFlags() complete.Flags { - return nil + return complete.Flags{ + "-verbose": complete.PredictNothing, + "-json": complete.PredictNothing, + "-t": complete.PredictNothing, + } } func (c *DeploymentStatusCommand) AutocompleteArgs() complete.Predictor { diff --git a/command/eval_status.go b/command/eval_status.go index e02bf96e5..dec7d771d 100644 --- a/command/eval_status.go +++ b/command/eval_status.go @@ -49,7 +49,12 @@ func (c *EvalStatusCommand) Synopsis() string { } func (c *EvalStatusCommand) AutocompleteFlags() complete.Flags { - return nil + return complete.Flags{ + "-json": complete.PredictNothing, + "-monitor": complete.PredictNothing, + "-t": complete.PredictNothing, + "-verbose": complete.PredictNothing, + } } func (c *EvalStatusCommand) AutocompleteArgs() complete.Predictor { diff --git a/command/fs.go b/command/fs.go index b43fdee35..7f5c04e64 100644 --- a/command/fs.go +++ b/command/fs.go @@ -79,8 +79,17 @@ func (f *FSCommand) Synopsis() string { return "Inspect the contents of an allocation directory" } -func (f *FSCommand) AutocompleteFlags() complete.Flags { - return nil +func (c *FSCommand) AutocompleteFlags() complete.Flags { + return complete.Flags{ + "-H": complete.PredictNothing, + "-verbose": complete.PredictNothing, + "-job": complete.PredictNothing, + "-stat": complete.PredictNothing, + "-f": complete.PredictNothing, + "-tail": complete.PredictNothing, + "-n": complete.PredictNothing, + "-c": complete.PredictNothing, + } } func (f *FSCommand) AutocompleteArgs() complete.Predictor { diff --git a/command/inspect.go b/command/inspect.go index 6f17b79b6..a50c993a5 100644 --- a/command/inspect.go +++ b/command/inspect.go @@ -42,7 +42,11 @@ func (c *InspectCommand) Synopsis() string { } func (c *InspectCommand) AutocompleteFlags() complete.Flags { - return nil + return complete.Flags{ + "-version": complete.PredictNothing, + "-json": complete.PredictNothing, + "-t": complete.PredictNothing, + } } func (c *InspectCommand) AutocompleteArgs() complete.Predictor { diff --git a/command/job_deployments.go b/command/job_deployments.go index d7918bf4b..4e57b8713 100644 --- a/command/job_deployments.go +++ b/command/job_deployments.go @@ -44,7 +44,12 @@ func (c *JobDeploymentsCommand) Synopsis() string { } func (c *JobDeploymentsCommand) AutocompleteFlags() complete.Flags { - return nil + return complete.Flags{ + "-json": complete.PredictNothing, + "-t": complete.PredictNothing, + "-latest": complete.PredictNothing, + "-verbose": complete.PredictNothing, + } } func (c *JobDeploymentsCommand) AutocompleteArgs() complete.Predictor { diff --git a/command/job_dispatch.go b/command/job_dispatch.go index 16d35b14b..3111dd84b 100644 --- a/command/job_dispatch.go +++ b/command/job_dispatch.go @@ -57,7 +57,11 @@ func (c *JobDispatchCommand) Synopsis() string { } func (c *JobDispatchCommand) AutocompleteFlags() complete.Flags { - return nil + return complete.Flags{ + "-meta": complete.PredictNothing, + "-detach": complete.PredictNothing, + "-verbose": complete.PredictNothing, + } } func (c *JobDispatchCommand) AutocompleteArgs() complete.Predictor { diff --git a/command/job_history.go b/command/job_history.go index 4e5c3062f..9aec8e13e 100644 --- a/command/job_history.go +++ b/command/job_history.go @@ -34,7 +34,7 @@ History Options: -p Display the difference between each job and its predecessor. - + -full Display the full job definition for each version. @@ -54,8 +54,14 @@ func (c *JobHistoryCommand) Synopsis() string { return "Display all tracked versions of a job" } -func (c *JobHistoryCommand) AutocompleteFlags() complete.Flags { - return nil +func (c *JobHistoryCommand) Autocompleteflags() complete.Flags { + return complete.Flags{ + "-p": complete.PredictNothing, + "-full": complete.PredictNothing, + "-version": complete.PredictNothing, + "-json": complete.PredictNothing, + "-t": complete.PredictNothing, + } } func (c *JobHistoryCommand) AutocompleteArgs() complete.Predictor { diff --git a/command/job_promote.go b/command/job_promote.go index 80d0eebf9..43b8643c7 100644 --- a/command/job_promote.go +++ b/command/job_promote.go @@ -53,7 +53,11 @@ func (c *JobPromoteCommand) Synopsis() string { } func (c *JobPromoteCommand) AutocompleteFlags() complete.Flags { - return nil + return complete.Flags{ + "-group": complete.PredictNothing, + "-detach": complete.PredictNothing, + "-verbose": complete.PredictNothing, + } } func (c *JobPromoteCommand) AutocompleteArgs() complete.Predictor { diff --git a/command/job_revert.go b/command/job_revert.go index 904246056..1100621e3 100644 --- a/command/job_revert.go +++ b/command/job_revert.go @@ -41,7 +41,10 @@ func (c *JobRevertCommand) Synopsis() string { } func (c *JobRevertCommand) AutocompleteFlags() complete.Flags { - return nil + return complete.Flags{ + "-detach": complete.PredictNothing, + "-verbose": complete.PredictNothing, + } } func (c *JobRevertCommand) AutocompleteArgs() complete.Predictor { diff --git a/command/job_status.go b/command/job_status.go index 8d6362311..27fcb4d1b 100644 --- a/command/job_status.go +++ b/command/job_status.go @@ -61,7 +61,12 @@ func (c *JobStatusCommand) Synopsis() string { } func (c *JobStatusCommand) AutocompleteFlags() complete.Flags { - return nil + return complete.Flags{ + "-all-allocs": complete.PredictNothing, + "-evals": complete.PredictNothing, + "-short": complete.PredictNothing, + "-verbose": complete.PredictNothing, + } } func (c *JobStatusCommand) AutocompleteArgs() complete.Predictor { diff --git a/command/keyring.go b/command/keyring.go index 7c74f5eaa..c7326cfaa 100644 --- a/command/keyring.go +++ b/command/keyring.go @@ -6,6 +6,7 @@ import ( "github.com/hashicorp/nomad/api" "github.com/mitchellh/cli" + "github.com/posener/complete" ) // KeyringCommand is a Command implementation that handles querying, installing, @@ -155,3 +156,15 @@ Keyring Options: func (c *KeyringCommand) Synopsis() string { return "Manages gossip layer encryption keys" } + +func (c *KeyringCommand) AutocompleteFlags() complete.Flags { + return complete.Flags{ + "-install": complete.PredictNothing, + "-list": complete.PredictNothing, + "-remove": complete.PredictNothing, + "-use": complete.PredictNothing, + } +} +func (c *KeyringCommand) AutocompleteArgs() complete.Predictor { + return complete.PredictNothing +} diff --git a/command/logs.go b/command/logs.go index 5fe4cab39..f7dc79414 100644 --- a/command/logs.go +++ b/command/logs.go @@ -61,8 +61,16 @@ func (l *LogsCommand) Synopsis() string { return "Streams the logs of a task." } -func (l *LogsCommand) AutocompleteFlags() complete.Flags { - return nil +func (c *LogsCommand) AutocompleteFlags() complete.Flags { + return complete.Flags{ + "-stderr": complete.PredictNothing, + "-verbose": complete.PredictNothing, + "-job": complete.PredictNothing, + "-f": complete.PredictNothing, + "-tail": complete.PredictNothing, + "-n": complete.PredictNothing, + "-c": complete.PredictNothing, + } } func (l *LogsCommand) AutocompleteArgs() complete.Predictor { diff --git a/command/node_drain.go b/command/node_drain.go index cec157abb..b8140e218 100644 --- a/command/node_drain.go +++ b/command/node_drain.go @@ -46,7 +46,12 @@ func (c *NodeDrainCommand) Synopsis() string { } func (c *NodeDrainCommand) AutocompleteFlags() complete.Flags { - return nil + return complete.Flags{ + "-disable": complete.PredictNothing, + "-enable": complete.PredictNothing, + "-self": complete.PredictNothing, + "-yes": complete.PredictNothing, + } } func (c *NodeDrainCommand) AutocompleteArgs() complete.Predictor { diff --git a/command/node_status.go b/command/node_status.go index 06b00ea25..6bec105bd 100644 --- a/command/node_status.go +++ b/command/node_status.go @@ -86,7 +86,15 @@ func (c *NodeStatusCommand) Synopsis() string { } func (c *NodeStatusCommand) AutocompleteFlags() complete.Flags { - return nil + return complete.Flags{ + "-allocs": complete.PredictNothing, + "-json": complete.PredictNothing, + "-self": complete.PredictNothing, + "-short": complete.PredictNothing, + "-stats": complete.PredictNothing, + "-t": complete.PredictNothing, + "-verbose": complete.PredictNothing, + } } func (c *NodeStatusCommand) AutocompleteArgs() complete.Predictor { diff --git a/command/operator_raft_list.go b/command/operator_raft_list.go index 9c7bac8b6..df51d1ba3 100644 --- a/command/operator_raft_list.go +++ b/command/operator_raft_list.go @@ -5,6 +5,7 @@ import ( "strings" "github.com/hashicorp/nomad/api" + "github.com/posener/complete" "github.com/ryanuber/columnize" ) @@ -32,6 +33,16 @@ List Peers Options: return strings.TrimSpace(helpText) } +func (c *OperatorRaftListCommand) AutocompleteFlags() complete.Flags { + return complete.Flags{ + "-stale": complete.PredictNothing, + } +} + +func (c *OperatorRaftListCommand) AutocompleteArgs() complete.Predictor { + return complete.PredictNothing +} + func (c *OperatorRaftListCommand) Synopsis() string { return "Display the current Raft peer configuration" } diff --git a/command/operator_raft_remove.go b/command/operator_raft_remove.go index bb5789cfd..2b3bdec07 100644 --- a/command/operator_raft_remove.go +++ b/command/operator_raft_remove.go @@ -5,6 +5,7 @@ import ( "strings" "github.com/hashicorp/nomad/api" + "github.com/posener/complete" ) type OperatorRaftRemoveCommand struct { @@ -36,6 +37,16 @@ Remove Peer Options: return strings.TrimSpace(helpText) } +func (c *OperatorRaftRemoveCommand) AutocompleteFlags() complete.Flags { + return complete.Flags{ + "-peer-address": complete.PredictNothing, + } +} + +func (c *OperatorRaftRemoveCommand) AutocompleteArgs() complete.Predictor { + return complete.PredictNothing +} + func (c *OperatorRaftRemoveCommand) Synopsis() string { return "Remove a Nomad server from the Raft configuration" } diff --git a/command/plan.go b/command/plan.go index 83d494ed6..daccab501 100644 --- a/command/plan.go +++ b/command/plan.go @@ -79,7 +79,10 @@ func (c *PlanCommand) Synopsis() string { } func (c *PlanCommand) AutocompleteFlags() complete.Flags { - return nil + return complete.Flags{ + "-diff": complete.PredictNothing, + "-verbose": complete.PredictNothing, + } } func (c *PlanCommand) AutocompleteArgs() complete.Predictor { diff --git a/command/run.go b/command/run.go index a386def27..2d6fbfff4 100644 --- a/command/run.go +++ b/command/run.go @@ -98,7 +98,13 @@ func (c *RunCommand) Synopsis() string { } func (c *RunCommand) AutocompleteFlags() complete.Flags { - return nil + return complete.Flags{ + "-check-index": complete.PredictNothing, + "-detach": complete.PredictNothing, + "-verbose": complete.PredictNothing, + "-vault-token": complete.PredictNothing, + "-output": complete.PredictNothing, + } } func (c *RunCommand) AutocompleteArgs() complete.Predictor { diff --git a/command/server_members.go b/command/server_members.go index 7a752e13b..efd8922b0 100644 --- a/command/server_members.go +++ b/command/server_members.go @@ -7,6 +7,7 @@ import ( "strings" "github.com/hashicorp/nomad/api" + "github.com/posener/complete" "github.com/ryanuber/columnize" ) @@ -35,6 +36,16 @@ Server Members Options: return strings.TrimSpace(helpText) } +func (c *ServerMembersCommand) AutocompleteFlags() complete.Flags { + return complete.Flags{ + "-detailed": complete.PredictNothing, + } +} + +func (c *ServerMembersCommand) AutocompleteArgs() complete.Predictor { + return complete.PredictNothing +} + func (c *ServerMembersCommand) Synopsis() string { return "Display a list of known servers and their status" } diff --git a/command/stop.go b/command/stop.go index e95192d35..59bc31e93 100644 --- a/command/stop.go +++ b/command/stop.go @@ -52,7 +52,12 @@ func (c *StopCommand) Synopsis() string { } func (c *StopCommand) AutocompleteFlags() complete.Flags { - return nil + return complete.Flags{ + "-detach": complete.PredictNothing, + "-purge": complete.PredictNothing, + "-yes": complete.PredictNothing, + "-verbose": complete.PredictNothing, + } } func (c *StopCommand) AutocompleteArgs() complete.Predictor {