[#1090] neofs-adm: Add history of commands to a storage configurator

It also persists between sessions.

Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
Evgenii Stratonikov 2022-02-07 14:08:20 +03:00 committed by Alex Vanin
parent 8263582dde
commit b3b3b8b20f

View file

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