Re-write argument parsing, implement skeleton of copy functionality

This commit is contained in:
2024-03-01 21:09:56 -05:00
parent 1ffd375950
commit 3ed3424adc
3 changed files with 20 additions and 0 deletions
+2
View File
@@ -192,4 +192,6 @@ func EntryListGen() {
// print trailing new lines for proper spacing after entry list is complete // print trailing new lines for proper spacing after entry list is complete
fmt.Print("\n\n") fmt.Print("\n\n")
os.Exit(0)
} }
+11
View File
@@ -3,9 +3,11 @@ package cli
import ( import (
"fmt" "fmt"
"github.com/rwinkhart/MUTN/src/offline" "github.com/rwinkhart/MUTN/src/offline"
"os"
) )
// EntryReader prints the decrypted contents of a libmutton entry in a human-readable format // EntryReader prints the decrypted contents of a libmutton entry in a human-readable format
// TODO implement password hiding
func EntryReader(decryptedEntry []string) { func EntryReader(decryptedEntry []string) {
fmt.Println() fmt.Println()
@@ -54,4 +56,13 @@ func EntryReader(decryptedEntry []string) {
if notesFlag { if notesFlag {
fmt.Println() 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)
}
} }
+7
View File
@@ -3,6 +3,7 @@ package cli
import ( import (
"fmt" "fmt"
"github.com/rwinkhart/MUTN/src/offline" "github.com/rwinkhart/MUTN/src/offline"
"os"
) )
// global constants used only in this file // 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 /<entry name>" ` + ansiBold + "Tip 1:" + offline.AnsiReset + ` You can quickly read an entry with "mutn /<entry name>"
` + ansiBold + "Tip 2:" + offline.AnsiReset + ` Type "mutn" (no arguments/options) to view a list of saved entries ` + 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\n\n")
os.Exit(0)
} }
func HelpAdd() { func HelpAdd() {
@@ -62,6 +64,7 @@ func HelpAdd() {
password/-p Add a password entry password/-p Add a password entry
note/-n Add a note entry note/-n Add a note entry
folder/-f Add a new folder for entries` + "\n\n") folder/-f Add a new folder for entries` + "\n\n")
os.Exit(0)
} }
func HelpEdit() { func HelpEdit() {
@@ -74,6 +77,7 @@ func HelpEdit() {
password/-p Change the password of an entry password/-p Change the password of an entry
url/-l Change the url attached to 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` + "\n\n")
os.Exit(0)
} }
func HelpCopy() { func HelpCopy() {
@@ -85,6 +89,7 @@ func HelpCopy() {
password/-p Copy the password in an entry to your clipboard password/-p Copy the password in an entry to your clipboard
url/-l Copy the url 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") note/-n Copy the first note line in an entry to your clipboard` + "\n\n")
os.Exit(0)
} }
func HelpGen() { func HelpGen() {
@@ -95,6 +100,7 @@ func HelpGen() {
update/-u Generate a password for an existing entry 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") ` + ansiBold + "Tip:" + offline.AnsiReset + " If no options are provided, a new password entry is generated\n\n")
os.Exit(0)
} }
func Version() { func Version() {
@@ -141,4 +147,5 @@ ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
"\n For more information, see:\n\n" + "\n For more information, see:\n\n" +
" https://github.com/rwinkhart/MUTN\n" + " https://github.com/rwinkhart/MUTN\n" +
" https://github.com/rwinkhart/libmutton\n\n") " https://github.com/rwinkhart/libmutton\n\n")
os.Exit(0)
} }