Skip to content

Commit

Permalink
refactor: revert named return and change displayDiscreetly to printDi…
Browse files Browse the repository at this point in the history
…screetly
  • Loading branch information
Halimao committed Dec 10, 2023
1 parent 973c5d8 commit ba41325
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion client/keys/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ func printCreate(ctx client.Context, cmd *cobra.Command, k *keyring.Record, show
return fmt.Errorf("failed to print mnemonic: %w", err)
}
} else {
if err = displayDiscreetly(ctx, cmd.ErrOrStderr(), "**Important** write this mnemonic phrase in a safe place.\nIt is the only way to recover your account if you ever forget your password.", mnemonic); err != nil {
if err = printDiscreetly(ctx, cmd.ErrOrStderr(), "**Important** write this mnemonic phrase in a safe place.\nIt is the only way to recover your account if you ever forget your password.", mnemonic); err != nil {
return fmt.Errorf("failed to print mnemonic: %w", err)
}
}
Expand Down
8 changes: 4 additions & 4 deletions client/keys/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,15 @@ func printTextRecords(w io.Writer, kos []KeyOutput) error {
return nil
}

// displayDiscreetly Print a secret string to an alternate screen, so the string isn't printed to the terminal.
func displayDiscreetly(clientCtx client.Context, w io.Writer, promptMsg, secretMsg string) (err error) {
// printDiscreetly Print a secret string to an alternate screen, so the string isn't printed to the terminal.
func printDiscreetly(clientCtx client.Context, w io.Writer, promptMsg, secretMsg string) error {
output := termenv.NewOutput(w)
output.AltScreen()
defer output.ExitAltScreen()
if _, err = fmt.Fprintf(output, "%s\n\n%s\n\nPress 'Enter' key to continue.", promptMsg, secretMsg); err != nil {
if _, err := fmt.Fprintf(output, "%s\n\n%s\n\nPress 'Enter' key to continue.", promptMsg, secretMsg); err != nil {
return err
}
if _, err = fmt.Scanln(); err != nil {
if _, err := fmt.Scanln(); err != nil {
return err
}
return nil
Expand Down

0 comments on commit ba41325

Please sign in to comment.