From 3ed3424adcc20b148289009af367cfe433a8f966 Mon Sep 17 00:00:00 2001 From: Randall Winkhart Date: Fri, 1 Mar 2024 21:09:56 -0500 Subject: [PATCH] Re-write argument parsing, implement skeleton of copy functionality --- src/cli/entryList.go | 2 ++ src/cli/entryReader.go | 11 +++++++++++ src/cli/printInfo.go | 7 +++++++ 3 files changed, 20 insertions(+) diff --git a/src/cli/entryList.go b/src/cli/entryList.go index 3a82391..6020c01 100644 --- a/src/cli/entryList.go +++ b/src/cli/entryList.go @@ -192,4 +192,6 @@ func EntryListGen() { // print trailing new lines for proper spacing after entry list is complete fmt.Print("\n\n") + + os.Exit(0) } diff --git a/src/cli/entryReader.go b/src/cli/entryReader.go index d0face5..67cbcd6 100644 --- a/src/cli/entryReader.go +++ b/src/cli/entryReader.go @@ -3,9 +3,11 @@ package cli import ( "fmt" "github.com/rwinkhart/MUTN/src/offline" + "os" ) // EntryReader prints the decrypted contents of a libmutton entry in a human-readable format +// TODO implement password hiding func EntryReader(decryptedEntry []string) { fmt.Println() @@ -54,4 +56,13 @@ func EntryReader(decryptedEntry []string) { if notesFlag { fmt.Println() } + os.Exit(0) +} + +func EntryReaderShortcut(targetLocation string) { + if isFile, _ := offline.TargetIsFile(targetLocation, true); isFile { + EntryReader(offline.DecryptGPG(targetLocation)) + } else { + fmt.Println(offline.AnsiError + "Failed to read \"" + targetLocation + "\" - it is a directory" + offline.AnsiReset) + } } diff --git a/src/cli/printInfo.go b/src/cli/printInfo.go index d6b8922..b8ddc1a 100644 --- a/src/cli/printInfo.go +++ b/src/cli/printInfo.go @@ -3,6 +3,7 @@ package cli import ( "fmt" "github.com/rwinkhart/MUTN/src/offline" + "os" ) // global constants used only in this file @@ -52,6 +53,7 @@ This program comes with absolutely no warranty; type "mutn version" for details. ` + 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") + os.Exit(0) } func HelpAdd() { @@ -62,6 +64,7 @@ func HelpAdd() { password/-p Add a password entry note/-n Add a note entry folder/-f Add a new folder for entries` + "\n\n") + os.Exit(0) } func HelpEdit() { @@ -74,6 +77,7 @@ func HelpEdit() { password/-p 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") + os.Exit(0) } func HelpCopy() { @@ -85,6 +89,7 @@ func HelpCopy() { password/-p 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) } func HelpGen() { @@ -95,6 +100,7 @@ func HelpGen() { update/-u Generate a password for an existing entry ` + ansiBold + "Tip:" + offline.AnsiReset + " If no options are provided, a new password entry is generated\n\n") + os.Exit(0) } func Version() { @@ -141,4 +147,5 @@ ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED "\n For more information, see:\n\n" + " https://github.com/rwinkhart/MUTN\n" + " https://github.com/rwinkhart/libmutton\n\n") + os.Exit(0) }