mirror of
https://github.com/rwinkhart/MUTN.git
synced 2026-09-05 16:47:20 -04:00
Reorganize function parameters to not specify repeat types
This commit is contained in:
@@ -37,7 +37,7 @@ func main() {
|
|||||||
case "show", "-s":
|
case "show", "-s":
|
||||||
cli.EntryReaderDecrypt(targetLocation, false)
|
cli.EntryReaderDecrypt(targetLocation, false)
|
||||||
case "copy":
|
case "copy":
|
||||||
backend.CopyArgument(targetLocation, 0, args[0])
|
backend.CopyArgument(args[0], targetLocation, 0)
|
||||||
case "edit":
|
case "edit":
|
||||||
cli.EditEntryField(targetLocation, true, 0)
|
cli.EditEntryField(targetLocation, true, 0)
|
||||||
case "gen":
|
case "gen":
|
||||||
@@ -82,7 +82,7 @@ func main() {
|
|||||||
default:
|
default:
|
||||||
cli.HelpCopy()
|
cli.HelpCopy()
|
||||||
}
|
}
|
||||||
backend.CopyArgument(targetLocation, field, args[0])
|
backend.CopyArgument(args[0], targetLocation, field)
|
||||||
case "edit":
|
case "edit":
|
||||||
var field int // indicates which (numbered) field to edit
|
var field int // indicates which (numbered) field to edit
|
||||||
switch args[3] {
|
switch args[3] {
|
||||||
|
|||||||
+3
-3
@@ -11,7 +11,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// CopyArgument copies a field from an entry to the clipboard
|
// CopyArgument copies a field from an entry to the clipboard
|
||||||
func CopyArgument(targetLocation string, field int, executableName string) {
|
func CopyArgument(executableName, targetLocation string, field int) {
|
||||||
if isFile, _ := TargetIsFile(targetLocation, true, 2); isFile {
|
if isFile, _ := TargetIsFile(targetLocation, true, 2); isFile {
|
||||||
|
|
||||||
decryptedEntry := DecryptGPG(targetLocation)
|
decryptedEntry := DecryptGPG(targetLocation)
|
||||||
@@ -41,7 +41,7 @@ func CopyArgument(targetLocation string, field int, executableName string) {
|
|||||||
|
|
||||||
for { // keep field copied to clipboard, refresh on 30-second intervals
|
for { // keep field copied to clipboard, refresh on 30-second intervals
|
||||||
currentTime := time.Now()
|
currentTime := time.Now()
|
||||||
copyField(GenTOTP(secret, currentTime, forSteam), "")
|
copyField("", GenTOTP(secret, currentTime, forSteam))
|
||||||
// sleep until next 30-second interval
|
// sleep until next 30-second interval
|
||||||
time.Sleep(time.Duration(30-(currentTime.Second()%30)) * time.Second)
|
time.Sleep(time.Duration(30-(currentTime.Second()%30)) * time.Second)
|
||||||
}
|
}
|
||||||
@@ -52,7 +52,7 @@ func CopyArgument(targetLocation string, field int, executableName string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// copy field to clipboard, launch clipboard clearing process
|
// copy field to clipboard, launch clipboard clearing process
|
||||||
copyField(copySubject, executableName)
|
copyField(executableName, copySubject)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import (
|
|||||||
// TODO MacOS support is entirely untested - I would appreciate feedback on this implementation
|
// TODO MacOS support is entirely untested - I would appreciate feedback on this implementation
|
||||||
|
|
||||||
// copyField copies a field from an entry to the clipboard
|
// copyField copies a field from an entry to the clipboard
|
||||||
func copyField(copySubject string, executableName string) {
|
func copyField(executableName, copySubject string) {
|
||||||
cmd := exec.Command("pbcopy")
|
cmd := exec.Command("pbcopy")
|
||||||
writeToStdin(cmd, copySubject)
|
writeToStdin(cmd, copySubject)
|
||||||
err := cmd.Run()
|
err := cmd.Run()
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// copyField copies a field from an entry to the clipboard
|
// copyField copies a field from an entry to the clipboard
|
||||||
func copyField(copySubject string, executableName string) {
|
func copyField(executableName, copySubject string) {
|
||||||
cmd := exec.Command("termux-clipboard-set")
|
cmd := exec.Command("termux-clipboard-set")
|
||||||
writeToStdin(cmd, copySubject)
|
writeToStdin(cmd, copySubject)
|
||||||
err := cmd.Run()
|
err := cmd.Run()
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// copyField copies a field from an entry to the clipboard
|
// copyField copies a field from an entry to the clipboard
|
||||||
func copyField(copySubject string, executableName string) {
|
func copyField(executableName, copySubject string) {
|
||||||
var envSet bool // track whether environment variables are set
|
var envSet bool // track whether environment variables are set
|
||||||
var cmd *exec.Cmd
|
var cmd *exec.Cmd
|
||||||
// determine whether to use wl-copy (Wayland) or xclip (X11)
|
// determine whether to use wl-copy (Wayland) or xclip (X11)
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// copyField copies a field from an entry to the clipboard
|
// copyField copies a field from an entry to the clipboard
|
||||||
func copyField(copySubject string, executableName string) {
|
func copyField(executableName, copySubject string) {
|
||||||
cmd := exec.Command("powershell.exe", "-c", fmt.Sprintf("echo '%s' | Set-Clipboard", strings.ReplaceAll(copySubject, "'", "''")))
|
cmd := exec.Command("powershell.exe", "-c", fmt.Sprintf("echo '%s' | Set-Clipboard", strings.ReplaceAll(copySubject, "'", "''")))
|
||||||
err := cmd.Run()
|
err := cmd.Run()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
+1
-1
@@ -22,7 +22,7 @@ func GetOldEntryData(targetLocation string, field int) []string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Rename renames oldLocation to newLocation
|
// Rename renames oldLocation to newLocation
|
||||||
func Rename(oldLocation string, newLocation string) {
|
func Rename(oldLocation, newLocation string) {
|
||||||
// ensure newLocation does not exist
|
// ensure newLocation does not exist
|
||||||
_, isAccessible := TargetIsFile(newLocation, false, 0)
|
_, isAccessible := TargetIsFile(newLocation, false, 0)
|
||||||
if isAccessible {
|
if isAccessible {
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ func determineIndentation(skippedDirList []bool, dirList []string, currentDirInd
|
|||||||
}
|
}
|
||||||
|
|
||||||
// processing for printing file entries (determines color, line wrapping, and prints)
|
// processing for printing file entries (determines color, line wrapping, and prints)
|
||||||
func printFileEntry(entry string, lastSlash int, charCounter int, colorAlternator int8, indent int) (int, int8) {
|
func printFileEntry(entry string, lastSlash, charCounter, indent int, colorAlternator int8) (int, int8) {
|
||||||
// determine color to print fileEntryName (alternate each time function is run)
|
// determine color to print fileEntryName (alternate each time function is run)
|
||||||
var colorCode string
|
var colorCode string
|
||||||
if colorAlternator > 0 {
|
if colorAlternator > 0 {
|
||||||
@@ -130,7 +130,7 @@ func EntryListGen() {
|
|||||||
printDirectoryHeader(vanityDirectory, indent)
|
printDirectoryHeader(vanityDirectory, indent)
|
||||||
}
|
}
|
||||||
|
|
||||||
charCounter, colorAlternator = printFileEntry(file, lastSlash, charCounter, colorAlternator, indent)
|
charCounter, colorAlternator = printFileEntry(file, lastSlash, charCounter, indent, colorAlternator)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import (
|
|||||||
const ansiShownPassword = "\033[38;5;10m"
|
const ansiShownPassword = "\033[38;5;10m"
|
||||||
|
|
||||||
// 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
|
||||||
func EntryReader(decryptedEntry []string, hideSecrets bool, syncEnabled bool) {
|
func EntryReader(decryptedEntry []string, hideSecrets, syncEnabled bool) {
|
||||||
fmt.Println()
|
fmt.Println()
|
||||||
|
|
||||||
for i := range decryptedEntry {
|
for i := range decryptedEntry {
|
||||||
|
|||||||
Reference in New Issue
Block a user