mirror of
https://github.com/rwinkhart/MUTN.git
synced 2026-08-27 20:36:29 -04:00
Rename "hidePassword" to "hideSecrets" for clarity
This commit is contained in:
+2
-2
@@ -8,7 +8,7 @@ import (
|
||||
|
||||
// AddEntry creates a new entry at targetLocation by taking user input via CLI prompts
|
||||
// entryType: 0 = standard (password), 1 = auto-generated password, 2 = note
|
||||
func AddEntry(targetLocation string, hidePassword bool, entryType uint8) {
|
||||
func AddEntry(targetLocation string, hideSecrets bool, entryType uint8) {
|
||||
_, isAccessible := backend.TargetIsFile(targetLocation, false, 0)
|
||||
if isAccessible {
|
||||
fmt.Println(backend.AnsiError + "Target location already exists" + backend.AnsiReset)
|
||||
@@ -42,5 +42,5 @@ func AddEntry(targetLocation string, hidePassword bool, entryType uint8) {
|
||||
}
|
||||
|
||||
// write and preview the new entry
|
||||
writeEntryCLI(targetLocation, unencryptedEntry, hidePassword)
|
||||
writeEntryCLI(targetLocation, unencryptedEntry, hideSecrets)
|
||||
}
|
||||
|
||||
+4
-4
@@ -23,7 +23,7 @@ func RenameCli(oldLocation string) {
|
||||
}
|
||||
|
||||
// EditEntryField edits a field of an entry at targetLocation (user input)
|
||||
func EditEntryField(targetLocation string, hidePassword bool, field int) {
|
||||
func EditEntryField(targetLocation string, hideSecrets bool, field int) {
|
||||
// fetch old entry data (with all required lines present)
|
||||
unencryptedEntry := backend.GetOldEntryData(targetLocation, field)
|
||||
|
||||
@@ -52,11 +52,11 @@ func EditEntryField(targetLocation string, hidePassword bool, field int) {
|
||||
}
|
||||
|
||||
// write and preview the modified entry
|
||||
writeEntryCLI(targetLocation, unencryptedEntry, hidePassword)
|
||||
writeEntryCLI(targetLocation, unencryptedEntry, hideSecrets)
|
||||
}
|
||||
|
||||
// GenUpdate generates a new password for an entry at targetLocation (user input)
|
||||
func GenUpdate(targetLocation string, hidePassword bool) {
|
||||
func GenUpdate(targetLocation string, hideSecrets bool) {
|
||||
// fetch old entry data
|
||||
unencryptedEntry := backend.GetOldEntryData(targetLocation, 0)
|
||||
|
||||
@@ -64,7 +64,7 @@ func GenUpdate(targetLocation string, hidePassword bool) {
|
||||
unencryptedEntry[0] = backend.StringGen(inputInt("Password length:", -1), inputBinary("Generate a complex (special characters) password?"), 0.2)
|
||||
|
||||
// write and preview the modified entry
|
||||
writeEntryCLI(targetLocation, unencryptedEntry, hidePassword)
|
||||
writeEntryCLI(targetLocation, unencryptedEntry, hideSecrets)
|
||||
}
|
||||
|
||||
// editNote uses the user-specified text editor to edit an existing note (or create a new one if baseNote is empty)
|
||||
|
||||
@@ -14,7 +14,7 @@ import (
|
||||
const ansiShownPassword = "\033[38;5;10m"
|
||||
|
||||
// EntryReader prints the decrypted contents of a libmutton entry in a human-readable format
|
||||
func EntryReader(decryptedEntry []string, hidePassword bool, syncEnabled bool) {
|
||||
func EntryReader(decryptedEntry []string, hideSecrets bool, syncEnabled bool) {
|
||||
fmt.Println()
|
||||
|
||||
for i := range decryptedEntry {
|
||||
@@ -22,7 +22,7 @@ func EntryReader(decryptedEntry []string, hidePassword bool, syncEnabled bool) {
|
||||
case 0:
|
||||
// if the first field (password) is not empty, print it
|
||||
if decryptedEntry[0] != "" {
|
||||
if !hidePassword {
|
||||
if !hideSecrets {
|
||||
fmt.Print(ansiDirectoryHeader + "Password:" + backend.AnsiReset + "\n" + ansiShownPassword + decryptedEntry[0] + backend.AnsiReset + "\n\n")
|
||||
} else {
|
||||
fmt.Print(ansiDirectoryHeader + "Password:" + backend.AnsiReset + "\n" + ansiEmptyDirectoryWarning + "End command in \"show\" or \"-s\" to view" + backend.AnsiReset + "\n\n")
|
||||
@@ -36,7 +36,7 @@ func EntryReader(decryptedEntry []string, hidePassword bool, syncEnabled bool) {
|
||||
case 2:
|
||||
// if the third field (TOTP secret) is not empty, print it
|
||||
if decryptedEntry[2] != "" {
|
||||
if !hidePassword {
|
||||
if !hideSecrets {
|
||||
fmt.Print(ansiDirectoryHeader + "TOTP Secret:" + backend.AnsiReset + "\n" + ansiShownPassword + decryptedEntry[2] + backend.AnsiReset + "\n\n")
|
||||
} else {
|
||||
fmt.Print(ansiDirectoryHeader + "TOTP Secret:" + backend.AnsiReset + "\n" + ansiEmptyDirectoryWarning + "End command in \"show\" or \"-s\" to view" + backend.AnsiReset + "\n\n")
|
||||
@@ -75,9 +75,9 @@ func EntryReader(decryptedEntry []string, hidePassword bool, syncEnabled bool) {
|
||||
}
|
||||
|
||||
// EntryReaderDecrypt is a wrapper for EntryReader that first decrypts a GPG-encrypted file before sending it to EntryReader
|
||||
func EntryReaderDecrypt(targetLocation string, hidePassword bool) {
|
||||
func EntryReaderDecrypt(targetLocation string, hideSecrets bool) {
|
||||
if isFile, _ := backend.TargetIsFile(targetLocation, true, 2); isFile {
|
||||
EntryReader(backend.DecryptGPG(targetLocation), hidePassword, false) // never sync if decrypting straight to EntryReader, as this means the entry could not have been modified
|
||||
EntryReader(backend.DecryptGPG(targetLocation), hideSecrets, false) // never sync if decrypting straight to EntryReader, as this means the entry could not have been modified
|
||||
}
|
||||
// do not exit, as this is the job of EntryReader
|
||||
}
|
||||
|
||||
@@ -64,13 +64,13 @@ func inputMenuGen(prompt string, options []string) int {
|
||||
}
|
||||
|
||||
// writeEntryCLI writes an entry to targetLocation and previews it (errors if no data is supplied)
|
||||
func writeEntryCLI(targetLocation string, unencryptedEntry []string, hidePassword bool) {
|
||||
func writeEntryCLI(targetLocation string, unencryptedEntry []string, hideSecrets bool) {
|
||||
if backend.EntryIsNotEmpty(unencryptedEntry) {
|
||||
// write the entry to the target location
|
||||
backend.WriteEntry(targetLocation, unencryptedEntry)
|
||||
// preview the entry
|
||||
fmt.Println(AnsiBold + "\nEntry Preview:" + backend.AnsiReset)
|
||||
EntryReader(unencryptedEntry, hidePassword, true)
|
||||
EntryReader(unencryptedEntry, hideSecrets, true)
|
||||
} else {
|
||||
fmt.Println(backend.AnsiError + "No data supplied for entry" + backend.AnsiReset)
|
||||
os.Exit(1)
|
||||
|
||||
Reference in New Issue
Block a user