forked from TrueCloudLab/frostfs-node
[#1090] neofs-adm: Add history of commands to a storage configurator
It also persists between sessions.
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
(cherry picked from commit b3b3b8b20f
)
This commit is contained in:
parent
00180a7ecf
commit
25b827e0fd
1 changed files with 9 additions and 1 deletions
|
@ -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
|
var c config
|
||||||
|
|
||||||
c.Wallet.Path, _ = cmd.Flags().GetString(walletFlag)
|
c.Wallet.Path, _ = cmd.Flags().GetString(walletFlag)
|
||||||
|
@ -217,8 +220,11 @@ func getWalletAccount(w *wallet.Wallet, prompt string) string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func getString(prompt string) string {
|
func getString(prompt string) string {
|
||||||
s, err := input.ReadLine(prompt)
|
s, err := readline.Line(prompt)
|
||||||
fatalOnErr(err)
|
fatalOnErr(err)
|
||||||
|
if s != "" {
|
||||||
|
_ = readline.AddHistory(s)
|
||||||
|
}
|
||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -259,6 +265,8 @@ func getPath(prompt string) string {
|
||||||
return p
|
return p
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_ = readline.AddHistory(p)
|
||||||
|
|
||||||
abs, err := filepath.Abs(p)
|
abs, err := filepath.Abs(p)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fatalOnErr(fmt.Errorf("can't create an absolute path: %w", err))
|
fatalOnErr(fmt.Errorf("can't create an absolute path: %w", err))
|
||||||
|
|
Loading…
Reference in a new issue