mirror of
https://github.com/rwinkhart/MUTN.git
synced 2026-09-02 15:17:24 -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
|
var unencryptedEntry []string
|
||||||
|
|
||||||
if !isNote {
|
if !isNote {
|
||||||
username := input("Username: ")
|
username := input("Username:")
|
||||||
password := inputHidden("Password: ")
|
password := inputHidden("Password:")
|
||||||
url := input("URL: ")
|
url := input("URL:")
|
||||||
// TODO prompt for optional note
|
if inputBinary("Add a note to this entry?") {
|
||||||
unencryptedEntry = []string{password, username, url}
|
note := newNote()
|
||||||
|
unencryptedEntry = append([]string{password, username, url}, note...)
|
||||||
|
} else {
|
||||||
|
unencryptedEntry = []string{password, username, url}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
note := newNote()
|
note := newNote()
|
||||||
unencryptedEntry = append([]string{"", "", ""}, note...)
|
unencryptedEntry = append([]string{"", "", ""}, note...)
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import (
|
|||||||
|
|
||||||
// input prompts the user for input and returns the input as a string
|
// input prompts the user for input and returns the input as a string
|
||||||
func input(prompt string) string {
|
func input(prompt string) string {
|
||||||
fmt.Print("\n" + prompt)
|
fmt.Print("\n" + prompt + " ")
|
||||||
var input string
|
var input string
|
||||||
fmt.Scanln(&input)
|
fmt.Scanln(&input)
|
||||||
return 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
|
// inputHidden prompts the user for input and returns the input as a string, hiding the input from the terminal
|
||||||
func inputHidden(prompt string) string {
|
func inputHidden(prompt string) string {
|
||||||
fmt.Print("\n" + prompt)
|
fmt.Print("\n" + prompt + " ")
|
||||||
byteInput, _ := terminal.ReadPassword(int(os.Stdin.Fd()))
|
byteInput, _ := terminal.ReadPassword(int(os.Stdin.Fd()))
|
||||||
password := string(byteInput)
|
password := string(byteInput)
|
||||||
fmt.Println()
|
fmt.Println()
|
||||||
return password
|
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
|
// newNote uses the user-specified text editor to create a new note and returns the note as a slice of strings
|
||||||
func newNote() []string {
|
func newNote() []string {
|
||||||
tempFile := offline.CreateTempFile()
|
tempFile := offline.CreateTempFile()
|
||||||
|
|||||||
Reference in New Issue
Block a user