From 833eaa9926fb8f116a07ff88b681f53ec9913cfd Mon Sep 17 00:00:00 2001 From: Randall Winkhart Date: Wed, 29 May 2024 12:50:47 -0400 Subject: [PATCH] Rename "hidePassword" to "hideSecrets" for clarity --- src/cli/add.go | 4 ++-- src/cli/edit.go | 8 ++++---- src/cli/entryReader.go | 10 +++++----- src/cli/utilitiesMisc.go | 4 ++-- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/cli/add.go b/src/cli/add.go index e7c0ddb..1952fac 100644 --- a/src/cli/add.go +++ b/src/cli/add.go @@ -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) } diff --git a/src/cli/edit.go b/src/cli/edit.go index 236d29f..c8cfa54 100644 --- a/src/cli/edit.go +++ b/src/cli/edit.go @@ -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) diff --git a/src/cli/entryReader.go b/src/cli/entryReader.go index 7d431bc..f54f269 100644 --- a/src/cli/entryReader.go +++ b/src/cli/entryReader.go @@ -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 } diff --git a/src/cli/utilitiesMisc.go b/src/cli/utilitiesMisc.go index d4f5dbb..0874836 100644 --- a/src/cli/utilitiesMisc.go +++ b/src/cli/utilitiesMisc.go @@ -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)