]> us-delaporte.pagekite.me Git - dotfiles.git/blobdiff - invoke/minetest/tasks.py
Fixup rmod
[dotfiles.git] / invoke / minetest / tasks.py
index a926cda527b73b70854912341051748988b97ddd..3c39102c6a6dbddc513d08ecc72f447373f92aef 100644 (file)
@@ -108,9 +108,28 @@ def bkmod(c, name=None):
 @task
 def rmod(c, name):
     '''Restore a backed up set of mods.'''
 @task
 def rmod(c, name):
     '''Restore a backed up set of mods.'''
-    bk = datetime.datetime.now().strftime("%Y%h%d%H%M")
-    c.run(f"mv {mod_dir} {root}/mods_{bk}")
-    c.run(f"mv {root}/mods_{name} {mod_dir}")
+    if len(os.listdir(f"{mod_dir}")) != 0:
+        bk = datetime.datetime.now().strftime("%Y%h%d%H%M")
+        print(f"Backed up non-emtpy mod dir to mods_{bk}.")
+        c.run(f"mv {mod_dir} {root}/mods_{bk}")
+    else:
+        print("Removing empty mod dir.")
+    c.run(f"mkdir -p {mod_dir}")
+    c.run(f"mv {root}/mods_{name}/* {mod_dir}/")
+    print(f"mods_{name} restored to mods")
+    print("ls of root")
     c.run(f"ls {root}")
     c.run(f"ls {root}")
+    print("ls of mods")
+    c.run(f"ls {root}/mods")
+
+@task
+def listmods(c):
+    print("ls of mods")
+    c.run(f"ls {root}/mods/")
+
+@task
+def logs(c, lines=20):
+    '''Output some logs'''
+    c.run(f"tail -n {lines} {root}/debug.txt")