From 25b827e0fd3220f3b6ba116500efb351b2e459d7 Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Mon, 7 Feb 2022 14:08:20 +0300 Subject: [PATCH] [#1090] neofs-adm: Add history of commands to a storage configurator It also persists between sessions. Signed-off-by: Evgenii Stratonikov (cherry picked from commit b3b3b8b20f46c3d82cf5cc648f289af436c13a1a) --- cmd/neofs-adm/internal/modules/storagecfg/root.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/cmd/neofs-adm/internal/modules/storagecfg/root.go b/cmd/neofs-adm/internal/modules/storagecfg/root.go index 7f0a3ee56..f06d0911d 100644 --- a/cmd/neofs-adm/internal/modules/storagecfg/root.go +++ b/cmd/neofs-adm/internal/modules/storagecfg/root.go @@ -89,6 +89,9 @@ func storageConfig(cmd *cobra.Command, args []string) { } } + historyPath := filepath.Join(os.TempDir(), "neofs-adm.history") + readline.SetHistoryPath(historyPath) + var c config c.Wallet.Path, _ = cmd.Flags().GetString(walletFlag) @@ -217,8 +220,11 @@ func getWalletAccount(w *wallet.Wallet, prompt string) string { } func getString(prompt string) string { - s, err := input.ReadLine(prompt) + s, err := readline.Line(prompt) fatalOnErr(err) + if s != "" { + _ = readline.AddHistory(s) + } return s } @@ -259,6 +265,8 @@ func getPath(prompt string) string { return p } + _ = readline.AddHistory(p) + abs, err := filepath.Abs(p) if err != nil { fatalOnErr(fmt.Errorf("can't create an absolute path: %w", err))