From 782f03e276a2dfa59ef49333c6028577f0846926 Mon Sep 17 00:00:00 2001 From: Randall Winkhart Date: Mon, 18 Mar 2024 12:59:18 -0400 Subject: [PATCH] Better document new blank option="password" shortcut, order arguments in order of expected use, list passwords first in entry reader --- src/cli/entryReader.go | 16 +++++----------- src/cli/printInfo.go | 40 ++++++++++++++++++++-------------------- 2 files changed, 25 insertions(+), 31 deletions(-) diff --git a/src/cli/entryReader.go b/src/cli/entryReader.go index 3ba9de9..25d29d9 100644 --- a/src/cli/entryReader.go +++ b/src/cli/entryReader.go @@ -16,19 +16,8 @@ func EntryReader(decryptedEntry []string, hidePassword bool, sync bool) { var notesFlag bool for i := range decryptedEntry { - - // if the entry only contains a password, skip the username field to avoid an index out of range error - if len(decryptedEntry) == 1 { - i = 1 - } - switch i { case 0: - // if the second field (username) is not empty, print it - if decryptedEntry[1] != "" { - fmt.Print(ansiDirectoryHeader + "Username:" + offline.AnsiReset + "\n" + decryptedEntry[1] + "\n\n") - } - case 1: // if the first field (password) is not empty, print it if decryptedEntry[0] != "" { if !hidePassword { @@ -37,6 +26,11 @@ func EntryReader(decryptedEntry []string, hidePassword bool, sync bool) { fmt.Print(ansiDirectoryHeader + "Password:" + offline.AnsiReset + "\n" + ansiEmptyDirectoryWarning + "End command in \"show\" or \"-s\" to view" + offline.AnsiReset + "\n\n") } } + case 1: + // if the second field (username) is not empty, print it + if decryptedEntry[1] != "" { + fmt.Print(ansiDirectoryHeader + "Username:" + offline.AnsiReset + "\n" + decryptedEntry[1] + "\n\n") + } case 2: // if the third field (url) is not empty, print it if decryptedEntry[2] != "" { diff --git a/src/cli/printInfo.go b/src/cli/printInfo.go index d751a29..05c0d65 100644 --- a/src/cli/printInfo.go +++ b/src/cli/printInfo.go @@ -24,35 +24,35 @@ This program comes with absolutely no warranty; type "mutn version" for details. version|-v Display version and license information init Set up MUTN (generates libmutton.ini) tweak Change configuration options - add Add an entry - gen Generate a new password - edit Edit an existing entry copy Copy details of an entry to your clipboard + edit Edit an existing entry + gen Generate a new password + add Add an entry shear Delete an existing entry sync Manually sync the entry directory ` + ansiBold + "Options:" + offline.AnsiReset + ` - add: - password|-pw Add a password entry - note|-n Add a note entry - folder|-f Add a new folder for entries - edit: - rename|-r Rename or relocate an entry - username|-u Change the username of an entry - password|-pw Change the password of an entry - url|-l Change the url attached to an entry - note|-n Change the note attached to an entry copy: + password|-pw| Copy the password of an entry to your clipboard username|-u Copy the username of an entry to your clipboard - password|-pw Copy the password of an entry to your clipboard url|-l Copy the url of an entry to your clipboard note|-n Copy the note of an entry to your clipboard + edit: + password|-pw| Change the password of an entry + username|-u Change the username of an entry + url|-l Change the url attached to an entry + note|-n Change the note attached to an entry + rename|-r Rename or relocate an entry gen: update|-u Generate a password for an existing entry + add: + password|-pw| Add a password entry + note|-n Add a note entry + folder|-f Add a new folder for entries ` + ansiBold + "Tip 1:" + offline.AnsiReset + ` You can quickly read an entry with "mutn /" ` + ansiBold + "Tip 2:" + offline.AnsiReset + ` Type "mutn" (no arguments/options) to view a list of saved entries -` + ansiBold + "Tip 3:" + offline.AnsiReset + ` Provide "add", "edit", "copy", or "gen" as the only argument to receive more specific help\n\n +` + ansiBold + "Tip 3:" + offline.AnsiReset + ` Provide "add", "edit", "copy", or "gen" as the only argument to receive more specific help ` + ansiBold + "Tip 4:" + offline.AnsiReset + " Using \"add\", \"edit\", or \"copy\" without specifying an option (field) will default to \"password\"\n\n") os.Exit(0) } @@ -62,7 +62,7 @@ func HelpAdd() { ` + ansiBold + "Options:" + offline.AnsiReset + ` add: - password|-pw Add a password entry + password|-pw| Add a password entry note|-n Add a note entry folder|-f Add a new folder for entries` + "\n\n") os.Exit(0) @@ -73,11 +73,11 @@ func HelpEdit() { ` + ansiBold + "Options:" + offline.AnsiReset + ` edit: - rename|-r Rename or relocate an entry + password|-pw| Change the password of an entry username|-u Change the username of an entry - password|-pw Change the password of an entry url|-l Change the url attached to an entry - note|-n Change the note attached to an entry` + "\n\n") + note|-n Change the note attached to an entry + rename|-r Rename or relocate an entry` + "\n\n") os.Exit(0) } @@ -86,8 +86,8 @@ func HelpCopy() { ` + ansiBold + "Options:" + offline.AnsiReset + ` copy: + password|-pw| Copy the password in an entry to your clipboard username|-u Copy the username in an entry to your clipboard - password|-pw Copy the password in an entry to your clipboard url|-l Copy the url in an entry to your clipboard note|-n Copy the first note line in an entry to your clipboard` + "\n\n") os.Exit(0)