Skip to content

Commit

Permalink
[#1090] neofs-adm: Add history of commands to a storage configurator
Browse files Browse the repository at this point in the history
It also persists between sessions.

Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
  • Loading branch information
fyrchik authored and alexvanin committed Feb 8, 2022
1 parent 8263582 commit b3b3b8b
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion cmd/neofs-adm/internal/modules/storagecfg/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -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))
Expand Down

0 comments on commit b3b3b8b

Please sign in to comment.