Implement notes editor (required rewrite of offline.ReadConfig)

This commit is contained in:
2024-03-05 17:11:53 -05:00
parent 1580227007
commit 11644b37ff
7 changed files with 110 additions and 62 deletions
+15 -8
View File
@@ -6,21 +6,28 @@ import (
"os"
)
// AddPasswordEntry prompts the user for all information relevant to a password entry and writes the entry to an encrypted file at targetLocation
func AddPasswordEntry(targetLocation string, hidePassword bool) {
// AddEntry creates a new entry at targetLocation by taking user input via CLI prompts
func AddEntry(targetLocation string, hidePassword bool, isNote bool) {
_, isAccessible := offline.TargetIsFile(targetLocation, false, 0)
if isAccessible {
fmt.Println(offline.AnsiError + "Target location already exists" + offline.AnsiReset)
os.Exit(1)
}
username := input("Username: ")
password := inputHidden("Password: ")
url := input("URL: ")
// TODO implement notes editor
notes := ""
var unencryptedEntry []string
if !isNote {
username := input("Username: ")
password := inputHidden("Password: ")
url := input("URL: ")
// TODO prompt for optional note
unencryptedEntry = []string{password, username, url}
} else {
note := newNote()
unencryptedEntry = append([]string{"", "", ""}, note...)
fmt.Println()
}
unencryptedEntry := []string{password, username, url, notes}
offline.WriteEntry(targetLocation, unencryptedEntry)
fmt.Println(ansiBold + "\nEntry Preview:" + offline.AnsiReset)
EntryReader(unencryptedEntry, hidePassword)