mirror of
https://github.com/rwinkhart/MUTN.git
synced 2026-08-28 04:46:41 -04:00
Port to latest libmutton development version (account for massive refactor)
This commit is contained in:
@@ -6,7 +6,7 @@ require (
|
|||||||
github.com/Trojan2021/BEAN v0.0.0-20241210230804-8f294833b514
|
github.com/Trojan2021/BEAN v0.0.0-20241210230804-8f294833b514
|
||||||
github.com/charmbracelet/glamour v0.7.0
|
github.com/charmbracelet/glamour v0.7.0
|
||||||
github.com/rwinkhart/go-boilerplate v0.0.0-20250509173525-20670ec7bb9c
|
github.com/rwinkhart/go-boilerplate v0.0.0-20250509173525-20670ec7bb9c
|
||||||
github.com/rwinkhart/libmutton v0.3.2-0.20250511210751-84d227b80379
|
github.com/rwinkhart/libmutton v0.3.2-0.20250512162603-36bbf88690c5
|
||||||
golang.org/x/term v0.32.0
|
golang.org/x/term v0.32.0
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -63,8 +63,8 @@ github.com/rwinkhart/go-boilerplate v0.0.0-20250509173525-20670ec7bb9c h1:RIMnYf
|
|||||||
github.com/rwinkhart/go-boilerplate v0.0.0-20250509173525-20670ec7bb9c/go.mod h1:cnzIF45I0FCOvE4YIB+26pLCUx2kWyY2llKYZruNaRY=
|
github.com/rwinkhart/go-boilerplate v0.0.0-20250509173525-20670ec7bb9c/go.mod h1:cnzIF45I0FCOvE4YIB+26pLCUx2kWyY2llKYZruNaRY=
|
||||||
github.com/rwinkhart/go-winio-easy-pipe-handles v0.0.0-20250407031321-96994a0e8410 h1:NhHwFM3Pgm6zRUfFKvi0p5ndjfFbVWsRwmmhyFlG4PE=
|
github.com/rwinkhart/go-winio-easy-pipe-handles v0.0.0-20250407031321-96994a0e8410 h1:NhHwFM3Pgm6zRUfFKvi0p5ndjfFbVWsRwmmhyFlG4PE=
|
||||||
github.com/rwinkhart/go-winio-easy-pipe-handles v0.0.0-20250407031321-96994a0e8410/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU=
|
github.com/rwinkhart/go-winio-easy-pipe-handles v0.0.0-20250407031321-96994a0e8410/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU=
|
||||||
github.com/rwinkhart/libmutton v0.3.2-0.20250511210751-84d227b80379 h1:5ZXtvrBd5COugtR9EtCsm+eGGlQKDdPMUO2DYHsVlHk=
|
github.com/rwinkhart/libmutton v0.3.2-0.20250512162603-36bbf88690c5 h1:/ll+6pzV+ivkUF4RMwMycr5UgSs8lmWkOSgqPOXVEYg=
|
||||||
github.com/rwinkhart/libmutton v0.3.2-0.20250511210751-84d227b80379/go.mod h1:oI6wUEZE/IyeO7aLRUA7+UlkulYOVRSiDbB2kuCOyfA=
|
github.com/rwinkhart/libmutton v0.3.2-0.20250512162603-36bbf88690c5/go.mod h1:oI6wUEZE/IyeO7aLRUA7+UlkulYOVRSiDbB2kuCOyfA=
|
||||||
github.com/rwinkhart/peercred-mini v0.1.0 h1:TiS6u8cEWzW55S9X4iVpU72Iuy/NG6rMUJMtUEVEFLw=
|
github.com/rwinkhart/peercred-mini v0.1.0 h1:TiS6u8cEWzW55S9X4iVpU72Iuy/NG6rMUJMtUEVEFLw=
|
||||||
github.com/rwinkhart/peercred-mini v0.1.0/go.mod h1:+x4Mxc2veE+YePSOpcUasjimh7n799c1KraLuQwHR20=
|
github.com/rwinkhart/peercred-mini v0.1.0/go.mod h1:+x4Mxc2veE+YePSOpcUasjimh7n799c1KraLuQwHR20=
|
||||||
github.com/rwinkhart/rcw v0.1.1 h1:ZvWauVTLGnS7y+I8dZEN+J/KTLuPA8wA+lNzTsn9Nuw=
|
github.com/rwinkhart/rcw v0.1.1 h1:ZvWauVTLGnS7y+I8dZEN+J/KTLuPA8wA+lNzTsn9Nuw=
|
||||||
|
|||||||
@@ -7,7 +7,9 @@ import (
|
|||||||
"github.com/rwinkhart/MUTN/src/cli"
|
"github.com/rwinkhart/MUTN/src/cli"
|
||||||
"github.com/rwinkhart/go-boilerplate/back"
|
"github.com/rwinkhart/go-boilerplate/back"
|
||||||
"github.com/rwinkhart/libmutton/core"
|
"github.com/rwinkhart/libmutton/core"
|
||||||
"github.com/rwinkhart/libmutton/sync"
|
"github.com/rwinkhart/libmutton/crypt"
|
||||||
|
"github.com/rwinkhart/libmutton/global"
|
||||||
|
"github.com/rwinkhart/libmutton/syncclient"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@@ -25,7 +27,7 @@ func main() {
|
|||||||
if strings.HasPrefix(args[1], "/") {
|
if strings.HasPrefix(args[1], "/") {
|
||||||
|
|
||||||
// store location of target entry
|
// store location of target entry
|
||||||
targetLocation := core.TargetLocationFormat(args[1])
|
targetLocation := global.TargetLocationFormat(args[1])
|
||||||
|
|
||||||
// entry reader shortcut (if no other arguments are supplied)
|
// entry reader shortcut (if no other arguments are supplied)
|
||||||
if argsCount == 2 {
|
if argsCount == 2 {
|
||||||
@@ -46,7 +48,7 @@ func main() {
|
|||||||
case "add":
|
case "add":
|
||||||
cli.AddEntry(targetLocation, true, 0)
|
cli.AddEntry(targetLocation, true, 0)
|
||||||
case "shear":
|
case "shear":
|
||||||
sync.ShearRemoteFromClient(args[1], false) // pass the incomplete path as the server and all clients (reading from the deletions directory) will have a different home directory
|
syncclient.ShearRemoteFromClient(args[1], false) // pass the incomplete path as the server and all clients (reading from the deletions directory) will have a different home directory
|
||||||
default:
|
default:
|
||||||
cli.HelpMain()
|
cli.HelpMain()
|
||||||
}
|
}
|
||||||
@@ -145,7 +147,7 @@ func main() {
|
|||||||
case "note", "-n":
|
case "note", "-n":
|
||||||
cli.AddEntry(targetLocation, true, 2)
|
cli.AddEntry(targetLocation, true, 2)
|
||||||
case "folder", "-f":
|
case "folder", "-f":
|
||||||
sync.AddFolderRemoteFromClient(args[1], false) // pass the incomplete path as the server will have a different home directory
|
syncclient.AddFolderRemoteFromClient(args[1], false) // pass the incomplete path as the server will have a different home directory
|
||||||
default:
|
default:
|
||||||
cli.HelpAdd()
|
cli.HelpAdd()
|
||||||
}
|
}
|
||||||
@@ -160,9 +162,9 @@ func main() {
|
|||||||
case "clipclear":
|
case "clipclear":
|
||||||
core.ClipClearArgument()
|
core.ClipClearArgument()
|
||||||
case "startrcwd":
|
case "startrcwd":
|
||||||
core.RCWDArgument()
|
crypt.RCWDArgument()
|
||||||
case "sync":
|
case "sync":
|
||||||
sync.RunJob(true, false)
|
syncclient.RunJob(true, false)
|
||||||
case "init":
|
case "init":
|
||||||
cli.TempInitCli()
|
cli.TempInitCli()
|
||||||
case "tweak":
|
case "tweak":
|
||||||
|
|||||||
+2
-2
@@ -4,7 +4,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/rwinkhart/go-boilerplate/front"
|
"github.com/rwinkhart/go-boilerplate/front"
|
||||||
"github.com/rwinkhart/libmutton/core"
|
"github.com/rwinkhart/libmutton/global"
|
||||||
"golang.org/x/term"
|
"golang.org/x/term"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -20,5 +20,5 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
core.GetPassphrase = front.InputHidden
|
global.GetPassphrase = front.InputHidden
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -9,14 +9,14 @@ import (
|
|||||||
"github.com/rwinkhart/go-boilerplate/back"
|
"github.com/rwinkhart/go-boilerplate/back"
|
||||||
"github.com/rwinkhart/go-boilerplate/front"
|
"github.com/rwinkhart/go-boilerplate/front"
|
||||||
"github.com/rwinkhart/libmutton/core"
|
"github.com/rwinkhart/libmutton/core"
|
||||||
"github.com/rwinkhart/libmutton/sync"
|
"github.com/rwinkhart/libmutton/syncclient"
|
||||||
)
|
)
|
||||||
|
|
||||||
// RenameCli renames an entry at oldLocationIncomplete to a new location (user input) on both the client and the server.
|
// RenameCli renames an entry at oldLocationIncomplete to a new location (user input) on both the client and the server.
|
||||||
func RenameCli(oldLocationIncomplete string) {
|
func RenameCli(oldLocationIncomplete string) {
|
||||||
// prompt user for new location and rename
|
// prompt user for new location and rename
|
||||||
newLocationIncomplete := front.Input("New location:")
|
newLocationIncomplete := front.Input("New location:")
|
||||||
sync.RenameRemoteFromClient(oldLocationIncomplete, newLocationIncomplete, false)
|
syncclient.RenameRemoteFromClient(oldLocationIncomplete, newLocationIncomplete, false)
|
||||||
|
|
||||||
// exit is done from sync.RenameRemoteFromClient
|
// exit is done from sync.RenameRemoteFromClient
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/rwinkhart/go-boilerplate/back"
|
"github.com/rwinkhart/go-boilerplate/back"
|
||||||
"github.com/rwinkhart/libmutton/sync"
|
"github.com/rwinkhart/libmutton/synccommon"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ANSI color constants used only in this file
|
// ANSI color constants used only in this file
|
||||||
@@ -79,7 +79,7 @@ func printFileEntry(entry string, lastSlash, charCounter, indent int, colorAlter
|
|||||||
|
|
||||||
// EntryListGen generates and displays the full libmutton entry list.
|
// EntryListGen generates and displays the full libmutton entry list.
|
||||||
func EntryListGen() {
|
func EntryListGen() {
|
||||||
fileList, dirList := sync.WalkEntryDir()
|
fileList, dirList := synccommon.WalkEntryDir()
|
||||||
|
|
||||||
// print header bar w/total entry count
|
// print header bar w/total entry count
|
||||||
fmt.Print("\n"+ansiBlackOnWhite, len(fileList), " libmutton entries:"+back.AnsiReset)
|
fmt.Print("\n"+ansiBlackOnWhite, len(fileList), " libmutton entries:"+back.AnsiReset)
|
||||||
|
|||||||
@@ -5,8 +5,8 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/rwinkhart/go-boilerplate/back"
|
"github.com/rwinkhart/go-boilerplate/back"
|
||||||
"github.com/rwinkhart/libmutton/core"
|
"github.com/rwinkhart/libmutton/crypt"
|
||||||
"github.com/rwinkhart/libmutton/sync"
|
"github.com/rwinkhart/libmutton/syncclient"
|
||||||
)
|
)
|
||||||
|
|
||||||
const ansiShownPassword = "\033[38;5;10m"
|
const ansiShownPassword = "\033[38;5;10m"
|
||||||
@@ -64,7 +64,7 @@ func EntryReader(decryptedEntry []string, hideSecrets, syncEnabled bool) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if syncEnabled {
|
if syncEnabled {
|
||||||
sync.RunJob(false, false)
|
syncclient.RunJob(false, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
@@ -73,7 +73,7 @@ func EntryReader(decryptedEntry []string, hideSecrets, syncEnabled bool) {
|
|||||||
// EntryReaderDecrypt is a wrapper for EntryReader that first decrypts an RCW-wrapped file before sending it to EntryReader.
|
// EntryReaderDecrypt is a wrapper for EntryReader that first decrypts an RCW-wrapped file before sending it to EntryReader.
|
||||||
func EntryReaderDecrypt(targetLocation string, hideSecrets bool) {
|
func EntryReaderDecrypt(targetLocation string, hideSecrets bool) {
|
||||||
if isFile, _ := back.TargetIsFile(targetLocation, true, 2); isFile {
|
if isFile, _ := back.TargetIsFile(targetLocation, true, 2); isFile {
|
||||||
EntryReader(core.DecryptFileToSlice(targetLocation), hideSecrets, false) // never sync if decrypting straight to EntryReader, as this means the entry could not have been modified
|
EntryReader(crypt.DecryptFileToSlice(targetLocation), hideSecrets, 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
|
// do not exit, as this is the job of EntryReader
|
||||||
}
|
}
|
||||||
|
|||||||
+7
-6
@@ -10,7 +10,8 @@ import (
|
|||||||
"github.com/rwinkhart/go-boilerplate/back"
|
"github.com/rwinkhart/go-boilerplate/back"
|
||||||
"github.com/rwinkhart/go-boilerplate/front"
|
"github.com/rwinkhart/go-boilerplate/front"
|
||||||
"github.com/rwinkhart/libmutton/core"
|
"github.com/rwinkhart/libmutton/core"
|
||||||
"github.com/rwinkhart/libmutton/sync"
|
"github.com/rwinkhart/libmutton/global"
|
||||||
|
"github.com/rwinkhart/libmutton/syncclient"
|
||||||
)
|
)
|
||||||
|
|
||||||
// TempInitCli initializes the MUTN environment based on user input.
|
// TempInitCli initializes the MUTN environment based on user input.
|
||||||
@@ -22,7 +23,7 @@ func TempInitCli() {
|
|||||||
configSSH := front.InputBinary("Configure SSH settings (for synchronization)?")
|
configSSH := front.InputBinary("Configure SSH settings (for synchronization)?")
|
||||||
if configSSH {
|
if configSSH {
|
||||||
// necessary SSH info
|
// necessary SSH info
|
||||||
fmt.Println(AnsiBold + "\nNote:" + back.AnsiReset + " Only key-based authentication is supported (keys may optionally be passphrase-protected).\nThe remote server must already be in your ~" + core.PathSeparator + ".ssh" + core.PathSeparator + "known_hosts file.")
|
fmt.Println(AnsiBold + "\nNote:" + back.AnsiReset + " Only key-based authentication is supported (keys may optionally be passphrase-protected).\nThe remote server must already be in your ~" + global.PathSeparator + ".ssh" + global.PathSeparator + "known_hosts file.")
|
||||||
sshUser := front.Input("Remote SSH username:")
|
sshUser := front.Input("Remote SSH username:")
|
||||||
sshPort := front.Input("Remote SSH port:")
|
sshPort := front.Input("Remote SSH port:")
|
||||||
sshIP := front.Input("Remote SSH IP/domain:")
|
sshIP := front.Input("Remote SSH IP/domain:")
|
||||||
@@ -31,7 +32,7 @@ func TempInitCli() {
|
|||||||
var sshKey string
|
var sshKey string
|
||||||
var sshKeyIsFile bool
|
var sshKeyIsFile bool
|
||||||
for !sshKeyIsFile {
|
for !sshKeyIsFile {
|
||||||
fallbackSSHKey := back.Home + core.PathSeparator + ".ssh" + core.PathSeparator + "id_ed25519"
|
fallbackSSHKey := back.Home + global.PathSeparator + ".ssh" + global.PathSeparator + "id_ed25519"
|
||||||
sshKey = cmp.Or(back.ExpandPathWithHome(front.Input("SSH private identity file path (falls back to \""+fallbackSSHKey+"\"):")), fallbackSSHKey)
|
sshKey = cmp.Or(back.ExpandPathWithHome(front.Input("SSH private identity file path (falls back to \""+fallbackSSHKey+"\"):")), fallbackSSHKey)
|
||||||
sshKeyIsFile, _ = back.TargetIsFile(sshKey, false, 0)
|
sshKeyIsFile, _ = back.TargetIsFile(sshKey, false, 0)
|
||||||
if !sshKeyIsFile {
|
if !sshKeyIsFile {
|
||||||
@@ -42,19 +43,19 @@ func TempInitCli() {
|
|||||||
sshKeyProtected := front.InputBinary("Is the identity file password-protected?")
|
sshKeyProtected := front.InputBinary("Is the identity file password-protected?")
|
||||||
|
|
||||||
// initialize libmutton directories
|
// initialize libmutton directories
|
||||||
oldDeviceID := core.DirInit(false)
|
oldDeviceID := global.DirInit(false)
|
||||||
|
|
||||||
// write config file (temporarily assigns sshEntryRoot and sshIsWindows to null to pass initial device ID registration)
|
// write config file (temporarily assigns sshEntryRoot and sshIsWindows to null to pass initial device ID registration)
|
||||||
core.WriteConfig([][3]string{{"MUTN", "textEditor", textEditor}, {"LIBMUTTON", "sshUser", sshUser}, {"LIBMUTTON", "sshIP", sshIP}, {"LIBMUTTON", "sshPort", sshPort}, {"LIBMUTTON", "sshKey", sshKey}, {"LIBMUTTON", "sshKeyProtected", strconv.FormatBool(sshKeyProtected)}, {"LIBMUTTON", "sshEntryRoot", "null"}, {"LIBMUTTON", "sshIsWindows", "false"}}, nil, false)
|
core.WriteConfig([][3]string{{"MUTN", "textEditor", textEditor}, {"LIBMUTTON", "sshUser", sshUser}, {"LIBMUTTON", "sshIP", sshIP}, {"LIBMUTTON", "sshPort", sshPort}, {"LIBMUTTON", "sshKey", sshKey}, {"LIBMUTTON", "sshKeyProtected", strconv.FormatBool(sshKeyProtected)}, {"LIBMUTTON", "sshEntryRoot", "null"}, {"LIBMUTTON", "sshIsWindows", "false"}}, nil, false)
|
||||||
|
|
||||||
// generate and register device ID
|
// generate and register device ID
|
||||||
sshEntryRoot, sshIsWindows := sync.DeviceIDGen(oldDeviceID)
|
sshEntryRoot, sshIsWindows := syncclient.DeviceIDGen(oldDeviceID)
|
||||||
|
|
||||||
// update config file with sshEntryRoot and sshIsWindows
|
// update config file with sshEntryRoot and sshIsWindows
|
||||||
core.WriteConfig([][3]string{{"LIBMUTTON", "sshEntryRoot", sshEntryRoot}, {"LIBMUTTON", "sshIsWindows", sshIsWindows}}, nil, true)
|
core.WriteConfig([][3]string{{"LIBMUTTON", "sshEntryRoot", sshEntryRoot}, {"LIBMUTTON", "sshIsWindows", sshIsWindows}}, nil, true)
|
||||||
} else {
|
} else {
|
||||||
// initialize libmutton directories
|
// initialize libmutton directories
|
||||||
core.DirInit(false)
|
global.DirInit(false)
|
||||||
|
|
||||||
// write config file
|
// write config file
|
||||||
core.WriteConfig([][3]string{{"MUTN", "textEditor", textEditor}}, nil, false)
|
core.WriteConfig([][3]string{{"MUTN", "textEditor", textEditor}}, nil, false)
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/rwinkhart/go-boilerplate/back"
|
"github.com/rwinkhart/go-boilerplate/back"
|
||||||
"github.com/rwinkhart/libmutton/core"
|
"github.com/rwinkhart/libmutton/global"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ANSI color constants used only in this file
|
// ANSI color constants used only in this file
|
||||||
@@ -151,7 +151,7 @@ func Version() {
|
|||||||
"\\" + ansiBlackOnWhite + " MUTN v" + MUTNVersion + " " + back.AnsiReset + ansiVersionOutline + "/\n" +
|
"\\" + ansiBlackOnWhite + " MUTN v" + MUTNVersion + " " + back.AnsiReset + ansiVersionOutline + "/\n" +
|
||||||
"\\" + ansiBlackOnWhite + " The Tripe Transmission Update " + back.AnsiReset + ansiVersionOutline + "/\n" +
|
"\\" + ansiBlackOnWhite + " The Tripe Transmission Update " + back.AnsiReset + ansiVersionOutline + "/\n" +
|
||||||
"\\" + ansiBlackOnWhite + " " + back.AnsiReset + ansiVersionOutline + "/\n" +
|
"\\" + ansiBlackOnWhite + " " + back.AnsiReset + ansiVersionOutline + "/\n" +
|
||||||
"\\" + ansiBlackOnWhite + " Built with libmutton v" + core.LibmuttonVersion + " " + back.AnsiReset + ansiVersionOutline + "/\n" +
|
"\\" + ansiBlackOnWhite + " Built with libmutton v" + global.LibmuttonVersion + " " + back.AnsiReset + ansiVersionOutline + "/\n" +
|
||||||
"\\" + ansiBlackOnWhite + " " + back.AnsiReset + ansiVersionOutline + "/\n" +
|
"\\" + ansiBlackOnWhite + " " + back.AnsiReset + ansiVersionOutline + "/\n" +
|
||||||
"\\" + ansiBlackOnWhite + " Copyright (c) 2024-2025: Randall Winkhart " + back.AnsiReset + ansiVersionOutline + "/\n" +
|
"\\" + ansiBlackOnWhite + " Copyright (c) 2024-2025: Randall Winkhart " + back.AnsiReset + ansiVersionOutline + "/\n" +
|
||||||
"\\" + ansiBlackOnWhite + " " + back.AnsiReset + ansiVersionOutline + "/\n" +
|
"\\" + ansiBlackOnWhite + " " + back.AnsiReset + ansiVersionOutline + "/\n" +
|
||||||
|
|||||||
Reference in New Issue
Block a user