mirror of
https://github.com/rwinkhart/MUTN.git
synced 2026-09-05 08:37:20 -04:00
Add TEMPORARY sshyp-sync shim so that MUTN can be tested while native sync is under development
This commit is contained in:
@@ -26,13 +26,13 @@ func main() {
|
|||||||
|
|
||||||
// entry reader shortcut (if no other arguments are supplied)
|
// entry reader shortcut (if no other arguments are supplied)
|
||||||
if argsCount == 2 {
|
if argsCount == 2 {
|
||||||
cli.EntryReaderShortcut(targetLocation, true)
|
cli.EntryReaderShortcut(targetLocation, true, false)
|
||||||
// perform other operations on the entry (if other arguments are supplied)
|
// perform other operations on the entry (if other arguments are supplied)
|
||||||
} else if argsCount == 3 {
|
} else if argsCount == 3 {
|
||||||
|
|
||||||
switch args[2] {
|
switch args[2] {
|
||||||
case "show", "-s":
|
case "show", "-s":
|
||||||
cli.EntryReaderShortcut(targetLocation, false)
|
cli.EntryReaderShortcut(targetLocation, false, false)
|
||||||
case "shear":
|
case "shear":
|
||||||
offline.Shear(targetLocation)
|
offline.Shear(targetLocation)
|
||||||
case "gen":
|
case "gen":
|
||||||
@@ -151,7 +151,8 @@ func main() {
|
|||||||
switch args[1] {
|
switch args[1] {
|
||||||
case "clipclear":
|
case "clipclear":
|
||||||
offline.ClipClearArgument()
|
offline.ClipClearArgument()
|
||||||
case "sync": // TODO online.Sync(), exit after run
|
case "sync":
|
||||||
|
cli.SshypSync() // TODO Remove after native sync is implemented
|
||||||
case "init": // TODO offline.Init(), exit after run
|
case "init": // TODO offline.Init(), exit after run
|
||||||
case "tweak": // TODO offline.Tweak(), exit after run
|
case "tweak": // TODO offline.Tweak(), exit after run
|
||||||
case "add":
|
case "add":
|
||||||
|
|||||||
@@ -9,7 +9,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, hidePassword bool) {
|
func EntryReader(decryptedEntry []string, hidePassword bool, sync bool) {
|
||||||
fmt.Println()
|
fmt.Println()
|
||||||
|
|
||||||
// track if extended notes have been printed (to avoid printing an extra newline)
|
// track if extended notes have been printed (to avoid printing an extra newline)
|
||||||
@@ -67,13 +67,18 @@ func EntryReader(decryptedEntry []string, hidePassword bool) {
|
|||||||
if notesFlag {
|
if notesFlag {
|
||||||
fmt.Println()
|
fmt.Println()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if sync {
|
||||||
|
SshypSync() // TODO Remove after native sync is implemented
|
||||||
|
}
|
||||||
|
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
// EntryReaderShortcut is a shortcut for EntryReader that decrypts a GPG-encrypted file and prints the contents
|
// EntryReaderShortcut is a shortcut for EntryReader that decrypts a GPG-encrypted file and prints the contents
|
||||||
func EntryReaderShortcut(targetLocation string, hidePassword bool) {
|
func EntryReaderShortcut(targetLocation string, hidePassword bool, sync bool) {
|
||||||
if isFile, _ := offline.TargetIsFile(targetLocation, true, 2); isFile {
|
if isFile, _ := offline.TargetIsFile(targetLocation, true, 2); isFile {
|
||||||
EntryReader(offline.DecryptGPG(targetLocation), hidePassword)
|
EntryReader(offline.DecryptGPG(targetLocation), hidePassword, sync)
|
||||||
}
|
}
|
||||||
// do not exit, as this is the job of EntryReader
|
// do not exit, as this is the job of EntryReader
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,9 +6,17 @@ import (
|
|||||||
"github.com/rwinkhart/MUTN/src/offline"
|
"github.com/rwinkhart/MUTN/src/offline"
|
||||||
"golang.org/x/crypto/ssh/terminal"
|
"golang.org/x/crypto/ssh/terminal"
|
||||||
"os"
|
"os"
|
||||||
|
"os/exec"
|
||||||
"strings"
|
"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
|
// input prompts the user for input and returns the input as a string
|
||||||
func input(prompt string) string {
|
func input(prompt string) string {
|
||||||
fmt.Print("\n" + prompt + " ")
|
fmt.Print("\n" + prompt + " ")
|
||||||
@@ -56,7 +64,7 @@ func writeEntryShortcut(targetLocation string, unencryptedEntry []string, hidePa
|
|||||||
trimmedEntry := offline.RemoveTrailingEmptyStrings(unencryptedEntry)
|
trimmedEntry := offline.RemoveTrailingEmptyStrings(unencryptedEntry)
|
||||||
offline.WriteEntry(targetLocation, trimmedEntry)
|
offline.WriteEntry(targetLocation, trimmedEntry)
|
||||||
fmt.Println(ansiBold + "\nEntry Preview:" + offline.AnsiReset)
|
fmt.Println(ansiBold + "\nEntry Preview:" + offline.AnsiReset)
|
||||||
EntryReader(trimmedEntry, hidePassword)
|
EntryReader(trimmedEntry, hidePassword, true)
|
||||||
} else {
|
} else {
|
||||||
fmt.Println(offline.AnsiError + "No data supplied for entry" + offline.AnsiReset)
|
fmt.Println(offline.AnsiError + "No data supplied for entry" + offline.AnsiReset)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
|
|||||||
Reference in New Issue
Block a user