Promote native sync to replace sshyp-based sync on all platforms

This commit is contained in:
2024-05-17 19:49:49 -04:00
parent 1230c8a437
commit bc51f20d41
3 changed files with 8 additions and 22 deletions
+2 -9
View File
@@ -28,14 +28,14 @@ func main() {
// entry reader shortcut (if no other arguments are supplied)
if argsCount == 2 {
cli.EntryReaderDecrypt(targetLocation, true, false)
cli.EntryReaderDecrypt(targetLocation, true)
// perform other operations on the entry (if other arguments are supplied)
} else if argsCount == 3 || (argsCount == 4 && (args[3] == "show" || args[3] == "-s")) {
if argsCount == 3 { // default to "password" if no field is specified (for copy, edit, and add)
switch args[2] {
case "show", "-s":
cli.EntryReaderDecrypt(targetLocation, false, false)
cli.EntryReaderDecrypt(targetLocation, false)
case "copy":
backend.CopyArgument(targetLocation, 0, args[0])
case "edit":
@@ -157,13 +157,6 @@ func main() {
case "clipclear":
backend.ClipClearArgument()
case "sync":
if !backend.Windows {
cli.SshypSync() // TODO Remove after native sync is implemented
} else {
fmt.Println(backend.AnsiError + "\"sync\" is not yet implemented" + backend.AnsiReset)
}
os.Exit(0)
case "synctest": // TODO Remove after native sync is implemented
sync.RunJob(true)
case "init":
cli.TempInitCli()
+6 -5
View File
@@ -2,6 +2,7 @@ package cli
import (
"fmt"
"github.com/rwinkhart/MUTN/src/sync"
"os"
"strings"
@@ -13,7 +14,7 @@ import (
const ansiShownPassword = "\033[38;5;10m"
// EntryReader prints the decrypted contents of a libmutton entry in a human-readable format
func EntryReader(decryptedEntry []string, hidePassword bool, sync bool) {
func EntryReader(decryptedEntry []string, hidePassword bool, syncEnabled bool) {
fmt.Println()
for i := range decryptedEntry {
@@ -57,17 +58,17 @@ func EntryReader(decryptedEntry []string, hidePassword bool, sync bool) {
}
}
if sync && !backend.IsWindows {
SshypSync() // TODO Remove after native sync is implemented
if syncEnabled {
sync.RunJob(false)
}
os.Exit(0)
}
// EntryReaderDecrypt is a wrapper for EntryReader that first decrypts a GPG-encrypted file before sending it to EntryReader
func EntryReaderDecrypt(targetLocation string, hidePassword bool, sync bool) {
func EntryReaderDecrypt(targetLocation string, hidePassword bool) {
if isFile, _ := backend.TargetIsFile(targetLocation, true, 2); isFile {
EntryReader(backend.DecryptGPG(targetLocation), hidePassword, sync)
EntryReader(backend.DecryptGPG(targetLocation), hidePassword, false) // never sync if decrypting straight to EntryReader, as this means the entry could not have been modified
}
// do not exit, as this is the job of EntryReader
}
-8
View File
@@ -6,17 +6,9 @@ import (
"github.com/rwinkhart/MUTN/src/backend"
"golang.org/x/crypto/ssh/terminal"
"os"
"os/exec"
"strings"
)
// TODO remove after native sync is implemented
func SshypSync() {
cmd := exec.Command("sshyp", "sync")
cmd.Stdout = os.Stdout
cmd.Run()
}
// input prompts the user for input and returns the input as a string
func input(prompt string) string {
fmt.Print("\n" + prompt + " ")