From 673d5408f4a17e6bb1c77e0e356446d830e96dd0 Mon Sep 17 00:00:00 2001 From: Thelonius Kort Date: Thu, 15 Jan 2026 22:36:59 +0100 Subject: [PATCH] Add imapsync calls and everything --- example.yaml | 16 ++++++++-------- imapsync.nu | 46 ++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 52 insertions(+), 10 deletions(-) diff --git a/example.yaml b/example.yaml index b331a81..008a82b 100644 --- a/example.yaml +++ b/example.yaml @@ -1,15 +1,15 @@ --- -- server1: mail.exampleserver1.de +- host1: mail.examplehost1.de user1: exampleuser1 - pass1: examplepass1 - server2: mail.exampleserver2.de + password1: examplepassword1 + host2: mail.examplehost2.de user2: exampleuser2 - pass2: examplepass2 + password2: examplepassword2 -- server1: mail.exampleserver1.de +- host1: mail.examplehost1.de user1: anotherexampleuser1 - pass1: anotherexamplepass1 - server2: mail.exampleserver2.de + password1: anotherexamplepassword1 + host2: mail.examplehost2.de user2: anotherexampleuser2 - pass2: anotherexamplepass2 + password2: anotherexamplepassword2 diff --git a/imapsync.nu b/imapsync.nu index 3882dff..420125f 100755 --- a/imapsync.nu +++ b/imapsync.nu @@ -1,8 +1,50 @@ #!/bin/env nu -def main [conffile] { +def main [] { + print "Usage: imapsync.nu [show_data|test_creds|synchronize] example.yaml" +} - open $conffile | each {|u| print $"server1: ($u.server1), user1: ($u.user1), \n server2: ($u.server2), user2: ($u.user2)" } +def "main show_data" [conffile] { + (open $conffile | + + each {|u| + + print $"host1: ($u.host1), user1: ($u.user1)," + print $"host2: ($u.host2), user2: ($u.user2)\n" + } + ) + "" +} + +def "main test_creds" [conffile] { + + (open $conffile | + + each {|u| + + print "Testing credentials for:" + print $"host1: ($u.host1), user1: ($u.user1)," + print $"host2: ($u.host2), user2: ($u.user2)\n" + + imapsync --justlogin --host1 $u.host1 --user1 $u.user1 --password1 $u.password1 --host2 $u.host2 --user2 $u.user2 --password2 $u.password2 | print + } + ) + "" +} + +def "main synchronize" [conffile] { + + (open $conffile | + + each {|u| + + print "Synchronizing:" + print $"host1: ($u.host1), user1: ($u.user1)," + print $"host2: ($u.host2), user2: ($u.user2)\n" + + imapsync --syncinternaldates --host1 $u.host1 --user1 $u.user1 --password1 $u.password1 --host2 $u.host2 --user2 $u.user2 --password2 $u.password2 | print + } + ) "" }