From 74e03514fc4f8174a6f2a0c607c1f8db3b93f8b2 Mon Sep 17 00:00:00 2001 From: hc-github-team-nomad-core <82989552+hc-github-team-nomad-core@users.noreply.github.com> Date: Mon, 30 Oct 2023 13:00:40 -0500 Subject: [PATCH] backport of commit 0748918a3a355ad5616e32c1aad041321a771418 (#18919) Co-authored-by: Dave May --- .changelog/18901.txt | 3 +++ command/operator_raft_info.go | 2 +- command/operator_raft_logs.go | 2 +- command/operator_raft_state.go | 6 ++++-- command/operator_snapshot_inspect.go | 2 +- command/operator_snapshot_restore.go | 2 +- command/operator_snapshot_state.go | 2 +- 7 files changed, 12 insertions(+), 7 deletions(-) create mode 100644 .changelog/18901.txt diff --git a/.changelog/18901.txt b/.changelog/18901.txt new file mode 100644 index 000000000..21d438919 --- /dev/null +++ b/.changelog/18901.txt @@ -0,0 +1,3 @@ +```release-note:improvement +cli: Add file prediction for operator raft/snapshot commands +``` diff --git a/command/operator_raft_info.go b/command/operator_raft_info.go index 4ce1be54d..032fa20a2 100644 --- a/command/operator_raft_info.go +++ b/command/operator_raft_info.go @@ -36,7 +36,7 @@ func (c *OperatorRaftInfoCommand) AutocompleteFlags() complete.Flags { } func (c *OperatorRaftInfoCommand) AutocompleteArgs() complete.Predictor { - return complete.PredictNothing + return complete.PredictFiles("*") } func (c *OperatorRaftInfoCommand) Synopsis() string { diff --git a/command/operator_raft_logs.go b/command/operator_raft_logs.go index 0816f65f9..9cda5d53d 100644 --- a/command/operator_raft_logs.go +++ b/command/operator_raft_logs.go @@ -45,7 +45,7 @@ func (c *OperatorRaftLogsCommand) AutocompleteFlags() complete.Flags { } func (c *OperatorRaftLogsCommand) AutocompleteArgs() complete.Predictor { - return complete.PredictNothing + return complete.PredictFiles("*") } func (c *OperatorRaftLogsCommand) Synopsis() string { diff --git a/command/operator_raft_state.go b/command/operator_raft_state.go index 3d8f844df..c16de8bd1 100644 --- a/command/operator_raft_state.go +++ b/command/operator_raft_state.go @@ -42,11 +42,13 @@ Options: } func (c *OperatorRaftStateCommand) AutocompleteFlags() complete.Flags { - return complete.Flags{} + return complete.Flags{ + "-last-index": complete.PredictNothing, + } } func (c *OperatorRaftStateCommand) AutocompleteArgs() complete.Predictor { - return complete.PredictNothing + return complete.PredictFiles("*") } func (c *OperatorRaftStateCommand) Synopsis() string { diff --git a/command/operator_snapshot_inspect.go b/command/operator_snapshot_inspect.go index 5d609cf8f..10d076528 100644 --- a/command/operator_snapshot_inspect.go +++ b/command/operator_snapshot_inspect.go @@ -33,7 +33,7 @@ func (c *OperatorSnapshotInspectCommand) AutocompleteFlags() complete.Flags { } func (c *OperatorSnapshotInspectCommand) AutocompleteArgs() complete.Predictor { - return complete.PredictNothing + return complete.PredictFiles("*.snap") } func (c *OperatorSnapshotInspectCommand) Synopsis() string { diff --git a/command/operator_snapshot_restore.go b/command/operator_snapshot_restore.go index 966417cd5..2b80f1d70 100644 --- a/command/operator_snapshot_restore.go +++ b/command/operator_snapshot_restore.go @@ -46,7 +46,7 @@ func (c *OperatorSnapshotRestoreCommand) AutocompleteFlags() complete.Flags { } func (c *OperatorSnapshotRestoreCommand) AutocompleteArgs() complete.Predictor { - return complete.PredictNothing + return complete.PredictFiles("*.snap") } func (c *OperatorSnapshotRestoreCommand) Synopsis() string { diff --git a/command/operator_snapshot_state.go b/command/operator_snapshot_state.go index c03ae3831..3f0ccdaa3 100644 --- a/command/operator_snapshot_state.go +++ b/command/operator_snapshot_state.go @@ -43,7 +43,7 @@ func (c *OperatorSnapshotStateCommand) AutocompleteFlags() complete.Flags { } func (c *OperatorSnapshotStateCommand) AutocompleteArgs() complete.Predictor { - return complete.PredictNothing + return complete.PredictFiles("*.snap") } func (c *OperatorSnapshotStateCommand) Synopsis() string {