Skip to content
Snippets Groups Projects
Commit e841c66b authored by STEVAN Antoine's avatar STEVAN Antoine :crab:
Browse files

make `inbreeding watch` better and more robust (dragoon/komodo!136)

- early return when format is bad twice
- refactor
parent 3f4c8ddb
No related branches found
No related tags found
No related merge requests found
use consts.nu CACHE
use path.nu [ "remove-cache-prefix" ]
def pretty-hash []: [ string -> string ] {
str substring 0..7
}
export def main [] {
watch $CACHE { |op, path, new_path|
if $op != "Create" {
return
}
let path = $path | remove-cache-prefix
let now = date now | format date "%Y-%m-%d %H:%M:%S"
let p = $path | remove-cache-prefix | parse "{seed}/{exp}/{id}" | into record
let p = $path | 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)"
let p = $path | parse "{seed}/{exp}" | into record
if $p == {} {
return $path
}
return $"($p.seed | pretty-hash) ($p.exp) at ($now)"
}
$"($p.seed | str substring 0..7) ($p.exp) ($p.id | str substring 0..7) at ($now)"
$"($p.seed | pretty-hash) ($p.exp) ($p.id | pretty-hash) at ($now)"
}
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment