diff --git a/bins/inbreeding/mod.nu b/bins/inbreeding/mod.nu index f3bdbd9dfce28c9c657c0b8fb205b39c5c01445d..4059fa7ca1fa0137ab13bb77b493458cef86d997 100644 --- a/bins/inbreeding/mod.nu +++ b/bins/inbreeding/mod.nu @@ -1,4 +1,5 @@ export use build.nu +export use watch.nu export use run.nu export use inspect.nu export use load.nu diff --git a/bins/inbreeding/watch.nu b/bins/inbreeding/watch.nu new file mode 100644 index 0000000000000000000000000000000000000000..69a5bdef6f5548565e6b9071346fb71aa3ce8a1d --- /dev/null +++ b/bins/inbreeding/watch.nu @@ -0,0 +1,20 @@ +use consts.nu CACHE +use path.nu [ "remove-cache-prefix" ] + +export def main [] { + watch $CACHE { |op, path, new_path| + if $op != "Create" { + return + } + + let now = date now | format date "%Y-%m-%d %H:%M:%S" + let p = $path | remove-cache-prefix | parse "{seed}/{exp}/{id}" | into record + + if $p == {} { + let p = $path | remove-cache-prefix | parse "{seed}/{exp}" | into record + return $"($p.seed | str substring 0..7) ($p.exp) at ($now)" + } + + $"($p.seed | str substring 0..7) ($p.exp) ($p.id | str substring 0..7) at ($now)" + } +}