streaming hell

This commit is contained in:
Schrottkatze 2025-10-14 14:22:39 +02:00
commit c3e08a9df4
No known key found for this signature in database
4 changed files with 55 additions and 6 deletions

View file

@ -8,10 +8,11 @@ def "main find" [
open $file --raw
| lines
| enumerate
| update item {|it| $it.item | parse '{current}#:{name}:-{template}-:#' }
| filter {|it| $it.item | is-not-empty}
| update item {|it| $it.item | parse '{current}# :{name}:-{template}-:#' }
| where {|it| $it.item | is-not-empty }
| flatten -a
| rename -c { index: line }
| to json
}
# TODO: support mroe then single template
@ -22,11 +23,12 @@ def "main edit" [
--preview
] {
let template = main find $file
| from json
| where name == $name
| first;
let new = $template.template
| str replace $"%($name)%" $to
| append $" #:($template.name):-($template.template)-:#"
| append $" # :($template.name):-($template.template)-:#"
| str join;
let rest = open $file --raw
| lines