mirror of
https://github.com/pocket-id/pocket-id.git
synced 2025-12-17 09:13:28 +03:00
feat: add "key-rotate" command (#709)
This commit is contained in:
committed by
GitHub
parent
15ece0ab30
commit
8c8fc2304d
24
backend/internal/utils/cmd_util.go
Normal file
24
backend/internal/utils/cmd_util.go
Normal file
@@ -0,0 +1,24 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// PromptForConfirmation prompts the user to answer "y" in the terminal
|
||||
func PromptForConfirmation(prompt string) (bool, error) {
|
||||
fmt.Print(prompt + " [y/N]: ")
|
||||
|
||||
reader := bufio.NewReader(os.Stdin)
|
||||
r, err := reader.ReadString('\n')
|
||||
if err != nil {
|
||||
return false, fmt.Errorf("failed to read response: %w", err)
|
||||
}
|
||||
r = strings.TrimSpace(strings.ToLower(r))
|
||||
|
||||
ok := r == "yes" || r == "y"
|
||||
|
||||
return ok, nil
|
||||
}
|
||||
Reference in New Issue
Block a user