mirror of
https://github.com/rwinkhart/MUTN.git
synced 2026-09-05 16:47:20 -04:00
Better document new blank option="password" shortcut, order arguments in order of expected use, list passwords first in entry reader
This commit is contained in:
@@ -21,7 +21,7 @@ _mutn_completions() {
|
|||||||
while read -r; do ITEM=${REPLY// /\\ }; COMPREPLY+=( "$ITEM" ); done < <( compgen -W "$(printf "'%s' " "${trimmed_paths[@]}")" -- "$cur" )
|
while read -r; do ITEM=${REPLY// /\\ }; COMPREPLY+=( "$ITEM" ); done < <( compgen -W "$(printf "'%s' " "${trimmed_paths[@]}")" -- "$cur" )
|
||||||
;;
|
;;
|
||||||
/* )
|
/* )
|
||||||
while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "add gen edit copy shear" -- "$cur" )
|
while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "copy edit gen add shear" -- "$cur" )
|
||||||
;;
|
;;
|
||||||
add )
|
add )
|
||||||
while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "password note folder" -- "$cur" )
|
while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "password note folder" -- "$cur" )
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ function mutn {
|
|||||||
[string]$entry,
|
[string]$entry,
|
||||||
|
|
||||||
[Parameter(Position = 1)]
|
[Parameter(Position = 1)]
|
||||||
[ArgumentCompletions('add', 'gen', 'edit', 'copy', 'shear')]
|
[ArgumentCompletions('copy', 'edit', 'gen', 'add', 'shear')]
|
||||||
[string]$argument,
|
[string]$argument,
|
||||||
|
|
||||||
[Parameter(Position = 2, ValueFromRemainingArguments=$true)]
|
[Parameter(Position = 2, ValueFromRemainingArguments=$true)]
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ case ${words[-2]} in
|
|||||||
compadd $trimmed_paths
|
compadd $trimmed_paths
|
||||||
;;
|
;;
|
||||||
/* )
|
/* )
|
||||||
compadd {add,gen,edit,copy,shear}
|
compadd {copy,edit,gen,add,shear}
|
||||||
;;
|
;;
|
||||||
add )
|
add )
|
||||||
compadd {password,note,folder}
|
compadd {password,note,folder}
|
||||||
|
|||||||
@@ -34,25 +34,25 @@ func main() {
|
|||||||
switch args[2] {
|
switch args[2] {
|
||||||
case "show", "-s":
|
case "show", "-s":
|
||||||
cli.EntryReaderShortcut(targetLocation, false, false)
|
cli.EntryReaderShortcut(targetLocation, false, false)
|
||||||
case "shear":
|
|
||||||
offline.Shear(targetLocation)
|
|
||||||
case "gen":
|
|
||||||
cli.AddEntry(targetLocation, true, 1)
|
|
||||||
case "copy":
|
case "copy":
|
||||||
offline.CopyArgument(targetLocation, 0, args[0])
|
offline.CopyArgument(targetLocation, 0, args[0])
|
||||||
case "edit":
|
case "edit":
|
||||||
cli.EditEntry(targetLocation, true, 0)
|
cli.EditEntry(targetLocation, true, 0)
|
||||||
|
case "gen":
|
||||||
|
cli.AddEntry(targetLocation, true, 1)
|
||||||
case "add":
|
case "add":
|
||||||
cli.AddEntry(targetLocation, true, 0)
|
cli.AddEntry(targetLocation, true, 0)
|
||||||
|
case "shear":
|
||||||
|
offline.Shear(targetLocation)
|
||||||
default:
|
default:
|
||||||
cli.HelpMain()
|
cli.HelpMain()
|
||||||
}
|
}
|
||||||
} else { // handle "show" or "-s" argument for gen, edit, and add
|
} else { // handle "show" or "-s" argument for gen, edit, and add
|
||||||
switch args[2] {
|
switch args[2] {
|
||||||
case "gen":
|
|
||||||
cli.AddEntry(targetLocation, false, 1)
|
|
||||||
case "edit":
|
case "edit":
|
||||||
cli.EditEntry(targetLocation, false, 0)
|
cli.EditEntry(targetLocation, false, 0)
|
||||||
|
case "gen":
|
||||||
|
cli.AddEntry(targetLocation, false, 1)
|
||||||
case "add":
|
case "add":
|
||||||
cli.AddEntry(targetLocation, false, 0)
|
cli.AddEntry(targetLocation, false, 0)
|
||||||
default:
|
default:
|
||||||
@@ -175,14 +175,14 @@ func main() {
|
|||||||
fmt.Println(offline.AnsiError + "\"tweak\" is not yet implemented" + offline.AnsiReset)
|
fmt.Println(offline.AnsiError + "\"tweak\" is not yet implemented" + offline.AnsiReset)
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
// TODO offline.Tweak()
|
// TODO offline.Tweak()
|
||||||
case "add":
|
|
||||||
cli.HelpAdd()
|
|
||||||
case "edit":
|
|
||||||
cli.HelpEdit()
|
|
||||||
case "copy":
|
case "copy":
|
||||||
cli.HelpCopy()
|
cli.HelpCopy()
|
||||||
|
case "edit":
|
||||||
|
cli.HelpEdit()
|
||||||
case "gen":
|
case "gen":
|
||||||
cli.HelpGen()
|
cli.HelpGen()
|
||||||
|
case "add":
|
||||||
|
cli.HelpAdd()
|
||||||
case "version", "-v":
|
case "version", "-v":
|
||||||
cli.Version()
|
cli.Version()
|
||||||
default:
|
default:
|
||||||
|
|||||||
+5
-11
@@ -16,19 +16,8 @@ func EntryReader(decryptedEntry []string, hidePassword bool, sync bool) {
|
|||||||
var notesFlag bool
|
var notesFlag bool
|
||||||
|
|
||||||
for i := range decryptedEntry {
|
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 {
|
switch i {
|
||||||
case 0:
|
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 the first field (password) is not empty, print it
|
||||||
if decryptedEntry[0] != "" {
|
if decryptedEntry[0] != "" {
|
||||||
if !hidePassword {
|
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")
|
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:
|
case 2:
|
||||||
// if the third field (url) is not empty, print it
|
// if the third field (url) is not empty, print it
|
||||||
if decryptedEntry[2] != "" {
|
if decryptedEntry[2] != "" {
|
||||||
|
|||||||
+20
-20
@@ -24,35 +24,35 @@ This program comes with absolutely no warranty; type "mutn version" for details.
|
|||||||
version|-v Display version and license information
|
version|-v Display version and license information
|
||||||
init Set up MUTN (generates libmutton.ini)
|
init Set up MUTN (generates libmutton.ini)
|
||||||
tweak Change configuration options
|
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
|
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
|
shear Delete an existing entry
|
||||||
sync Manually sync the entry directory
|
sync Manually sync the entry directory
|
||||||
|
|
||||||
` + ansiBold + "Options:" + offline.AnsiReset + `
|
` + 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:
|
copy:
|
||||||
|
password|-pw|<blank> Copy the password of an entry to your clipboard
|
||||||
username|-u Copy the username 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
|
url|-l Copy the url of an entry to your clipboard
|
||||||
note|-n Copy the note of an entry to your clipboard
|
note|-n Copy the note of an entry to your clipboard
|
||||||
|
edit:
|
||||||
|
password|-pw|<blank> 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:
|
gen:
|
||||||
update|-u Generate a password for an existing entry
|
update|-u Generate a password for an existing entry
|
||||||
|
add:
|
||||||
|
password|-pw|<blank> 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 /<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
|
||||||
` + ansiBold + "Tip 4:" + offline.AnsiReset + " Using \"add\", \"edit\", or \"copy\" without specifying an option (field) will default to \"password\"\n\n")
|
` + ansiBold + "Tip 4:" + offline.AnsiReset + " Using \"add\", \"edit\", or \"copy\" without specifying an option (field) will default to \"password\"\n\n")
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
@@ -62,7 +62,7 @@ func HelpAdd() {
|
|||||||
|
|
||||||
` + ansiBold + "Options:" + offline.AnsiReset + `
|
` + ansiBold + "Options:" + offline.AnsiReset + `
|
||||||
add:
|
add:
|
||||||
password|-pw Add a password entry
|
password|-pw|<blank> 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)
|
os.Exit(0)
|
||||||
@@ -73,11 +73,11 @@ func HelpEdit() {
|
|||||||
|
|
||||||
` + ansiBold + "Options:" + offline.AnsiReset + `
|
` + ansiBold + "Options:" + offline.AnsiReset + `
|
||||||
edit:
|
edit:
|
||||||
rename|-r Rename or relocate an entry
|
password|-pw|<blank> Change the password of an entry
|
||||||
username|-u Change the username 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
|
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)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -86,8 +86,8 @@ func HelpCopy() {
|
|||||||
|
|
||||||
` + ansiBold + "Options:" + offline.AnsiReset + `
|
` + ansiBold + "Options:" + offline.AnsiReset + `
|
||||||
copy:
|
copy:
|
||||||
|
password|-pw|<blank> Copy the password in an entry to your clipboard
|
||||||
username|-u Copy the username 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
|
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)
|
os.Exit(0)
|
||||||
|
|||||||
Reference in New Issue
Block a user