diff --git a/go.mod b/go.mod index 0c9507f..19785b1 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ require ( github.com/Trojan2021/BEAN v0.0.0-20241210230804-8f294833b514 github.com/charmbracelet/glamour v0.7.0 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 ) diff --git a/go.sum b/go.sum index aed3942..bc02cc1 100644 --- a/go.sum +++ b/go.sum @@ -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-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/libmutton v0.3.2-0.20250511210751-84d227b80379 h1:5ZXtvrBd5COugtR9EtCsm+eGGlQKDdPMUO2DYHsVlHk= -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 h1:/ll+6pzV+ivkUF4RMwMycr5UgSs8lmWkOSgqPOXVEYg= +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/go.mod h1:+x4Mxc2veE+YePSOpcUasjimh7n799c1KraLuQwHR20= github.com/rwinkhart/rcw v0.1.1 h1:ZvWauVTLGnS7y+I8dZEN+J/KTLuPA8wA+lNzTsn9Nuw= diff --git a/mutn.go b/mutn.go index a962dff..960f1a2 100644 --- a/mutn.go +++ b/mutn.go @@ -7,7 +7,9 @@ import ( "github.com/rwinkhart/MUTN/src/cli" "github.com/rwinkhart/go-boilerplate/back" "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() { @@ -25,7 +27,7 @@ func main() { if strings.HasPrefix(args[1], "/") { // store location of target entry - targetLocation := core.TargetLocationFormat(args[1]) + targetLocation := global.TargetLocationFormat(args[1]) // entry reader shortcut (if no other arguments are supplied) if argsCount == 2 { @@ -46,7 +48,7 @@ func main() { case "add": cli.AddEntry(targetLocation, true, 0) 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: cli.HelpMain() } @@ -145,7 +147,7 @@ func main() { case "note", "-n": cli.AddEntry(targetLocation, true, 2) 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: cli.HelpAdd() } @@ -160,9 +162,9 @@ func main() { case "clipclear": core.ClipClearArgument() case "startrcwd": - core.RCWDArgument() + crypt.RCWDArgument() case "sync": - sync.RunJob(true, false) + syncclient.RunJob(true, false) case "init": cli.TempInitCli() case "tweak": diff --git a/src/cli/1globals.go b/src/cli/1globals.go index 973a2af..288351d 100644 --- a/src/cli/1globals.go +++ b/src/cli/1globals.go @@ -4,7 +4,7 @@ import ( "os" "github.com/rwinkhart/go-boilerplate/front" - "github.com/rwinkhart/libmutton/core" + "github.com/rwinkhart/libmutton/global" "golang.org/x/term" ) @@ -20,5 +20,5 @@ const ( ) func init() { - core.GetPassphrase = front.InputHidden + global.GetPassphrase = front.InputHidden } diff --git a/src/cli/edit.go b/src/cli/edit.go index 56a00f2..4eb0d75 100644 --- a/src/cli/edit.go +++ b/src/cli/edit.go @@ -9,14 +9,14 @@ import ( "github.com/rwinkhart/go-boilerplate/back" "github.com/rwinkhart/go-boilerplate/front" "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. func RenameCli(oldLocationIncomplete string) { // prompt user for new location and rename newLocationIncomplete := front.Input("New location:") - sync.RenameRemoteFromClient(oldLocationIncomplete, newLocationIncomplete, false) + syncclient.RenameRemoteFromClient(oldLocationIncomplete, newLocationIncomplete, false) // exit is done from sync.RenameRemoteFromClient } diff --git a/src/cli/entryList.go b/src/cli/entryList.go index 68928d5..a2bcf9c 100644 --- a/src/cli/entryList.go +++ b/src/cli/entryList.go @@ -6,7 +6,7 @@ import ( "strings" "github.com/rwinkhart/go-boilerplate/back" - "github.com/rwinkhart/libmutton/sync" + "github.com/rwinkhart/libmutton/synccommon" ) // 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. func EntryListGen() { - fileList, dirList := sync.WalkEntryDir() + fileList, dirList := synccommon.WalkEntryDir() // print header bar w/total entry count fmt.Print("\n"+ansiBlackOnWhite, len(fileList), " libmutton entries:"+back.AnsiReset) diff --git a/src/cli/entryReader.go b/src/cli/entryReader.go index a4ffba3..1fc77d6 100644 --- a/src/cli/entryReader.go +++ b/src/cli/entryReader.go @@ -5,8 +5,8 @@ import ( "os" "github.com/rwinkhart/go-boilerplate/back" - "github.com/rwinkhart/libmutton/core" - "github.com/rwinkhart/libmutton/sync" + "github.com/rwinkhart/libmutton/crypt" + "github.com/rwinkhart/libmutton/syncclient" ) const ansiShownPassword = "\033[38;5;10m" @@ -64,7 +64,7 @@ func EntryReader(decryptedEntry []string, hideSecrets, syncEnabled bool) { } if syncEnabled { - sync.RunJob(false, false) + syncclient.RunJob(false, false) } 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. func EntryReaderDecrypt(targetLocation string, hideSecrets bool) { 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 } diff --git a/src/cli/init.go b/src/cli/init.go index 72901c1..61605ca 100644 --- a/src/cli/init.go +++ b/src/cli/init.go @@ -10,7 +10,8 @@ import ( "github.com/rwinkhart/go-boilerplate/back" "github.com/rwinkhart/go-boilerplate/front" "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. @@ -22,7 +23,7 @@ func TempInitCli() { configSSH := front.InputBinary("Configure SSH settings (for synchronization)?") if configSSH { // 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:") sshPort := front.Input("Remote SSH port:") sshIP := front.Input("Remote SSH IP/domain:") @@ -31,7 +32,7 @@ func TempInitCli() { var sshKey string var sshKeyIsFile bool 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) sshKeyIsFile, _ = back.TargetIsFile(sshKey, false, 0) if !sshKeyIsFile { @@ -42,19 +43,19 @@ func TempInitCli() { sshKeyProtected := front.InputBinary("Is the identity file password-protected?") // 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) 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 - sshEntryRoot, sshIsWindows := sync.DeviceIDGen(oldDeviceID) + sshEntryRoot, sshIsWindows := syncclient.DeviceIDGen(oldDeviceID) // update config file with sshEntryRoot and sshIsWindows core.WriteConfig([][3]string{{"LIBMUTTON", "sshEntryRoot", sshEntryRoot}, {"LIBMUTTON", "sshIsWindows", sshIsWindows}}, nil, true) } else { // initialize libmutton directories - core.DirInit(false) + global.DirInit(false) // write config file core.WriteConfig([][3]string{{"MUTN", "textEditor", textEditor}}, nil, false) diff --git a/src/cli/printInfo.go b/src/cli/printInfo.go index c0928fe..47bba2c 100644 --- a/src/cli/printInfo.go +++ b/src/cli/printInfo.go @@ -5,7 +5,7 @@ import ( "os" "github.com/rwinkhart/go-boilerplate/back" - "github.com/rwinkhart/libmutton/core" + "github.com/rwinkhart/libmutton/global" ) // ANSI color constants used only in this file @@ -151,7 +151,7 @@ func Version() { "\\" + ansiBlackOnWhite + " MUTN v" + MUTNVersion + " " + back.AnsiReset + ansiVersionOutline + "/\n" + "\\" + ansiBlackOnWhite + " The Tripe Transmission Update " + 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 + " Copyright (c) 2024-2025: Randall Winkhart " + back.AnsiReset + ansiVersionOutline + "/\n" + "\\" + ansiBlackOnWhite + " " + back.AnsiReset + ansiVersionOutline + "/\n" +