mirror of
https://github.com/rwinkhart/MUTN.git
synced 2026-08-28 04:46:41 -04:00
Allow optionally adding notes to new password entries
This commit is contained in:
+9
-5
@@ -17,11 +17,15 @@ func AddEntry(targetLocation string, hidePassword bool, isNote bool) {
|
||||
var unencryptedEntry []string
|
||||
|
||||
if !isNote {
|
||||
username := input("Username: ")
|
||||
password := inputHidden("Password: ")
|
||||
url := input("URL: ")
|
||||
// TODO prompt for optional note
|
||||
unencryptedEntry = []string{password, username, url}
|
||||
username := input("Username:")
|
||||
password := inputHidden("Password:")
|
||||
url := input("URL:")
|
||||
if inputBinary("Add a note to this entry?") {
|
||||
note := newNote()
|
||||
unencryptedEntry = append([]string{password, username, url}, note...)
|
||||
} else {
|
||||
unencryptedEntry = []string{password, username, url}
|
||||
}
|
||||
} else {
|
||||
note := newNote()
|
||||
unencryptedEntry = append([]string{"", "", ""}, note...)
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
|
||||
// input prompts the user for input and returns the input as a string
|
||||
func input(prompt string) string {
|
||||
fmt.Print("\n" + prompt)
|
||||
fmt.Print("\n" + prompt + " ")
|
||||
var input string
|
||||
fmt.Scanln(&input)
|
||||
return input
|
||||
@@ -19,13 +19,24 @@ func input(prompt string) string {
|
||||
|
||||
// inputHidden prompts the user for input and returns the input as a string, hiding the input from the terminal
|
||||
func inputHidden(prompt string) string {
|
||||
fmt.Print("\n" + prompt)
|
||||
fmt.Print("\n" + prompt + " ")
|
||||
byteInput, _ := terminal.ReadPassword(int(os.Stdin.Fd()))
|
||||
password := string(byteInput)
|
||||
fmt.Println()
|
||||
return password
|
||||
}
|
||||
|
||||
// inputBinary prompts the user with a yes/no question and returns the response as a boolean
|
||||
func inputBinary(prompt string) bool {
|
||||
reader := bufio.NewReader(os.Stdin)
|
||||
fmt.Print("\n" + prompt + " (y/N) ")
|
||||
char, _, _ := reader.ReadRune()
|
||||
if char == 'y' || char == 'Y' {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// newNote uses the user-specified text editor to create a new note and returns the note as a slice of strings
|
||||
func newNote() []string {
|
||||
tempFile := offline.CreateTempFile()
|
||||
|
||||
Reference in New Issue
Block a user