shrub/pkg/arvo/gen/hood/tomb.hoon

64 lines
1.9 KiB
Plaintext
Raw Normal View History

2022-04-13 07:02:37 +03:00
:: Perform minimal norm change to delete a file, use =dry & for dry run
::
2022-04-09 07:20:02 +03:00
:: TODO: recognize when it's going to fail because it's in the head of
2022-04-13 07:02:37 +03:00
:: a desk, and maybe offer to |rm
2022-04-09 07:20:02 +03:00
::
:- %say
|= [[now=@da eny=@uvJ bec=beak] [target=path ~] dry=_|]
:- %helm-pans
=+ .^(=arch %cy target)
?~ fil.arch
[%d %flog %text "tomb: not a file"]~ :: should recurse
=/ =lobe:clay u.fil.arch
=+ .^(=rang:clay %cx /(scot %p p.bec)//(scot %da now)/rang)
=+ .^(=cone:clay %cx /(scot %p p.bec)//(scot %da now)/domes)
=/ domes=(list [[=ship =desk] =dome:clay]) ~(tap by cone)
=/ norms
|^
|- ^- (set [ship desk tako:clay norm:clay path])
?~ domes
~
=/ n 1
=/ =aeon:clay 1
%- ~(uni in $(domes t.domes))
|- ^- (set [ship desk tako:clay norm:clay path])
?: (lth let.dome.i.domes aeon)
~
=/ =tako:clay (~(got by hit.dome.i.domes) aeon)
=/ paths (draw-tako ship.i.domes desk.i.domes dome.i.domes tako)
(~(uni in paths) $(aeon +(aeon)))
::
++ draw-tako
|= [=ship =desk =dome:clay =tako:clay]
^- (set [^ship ^desk tako:clay norm:clay path])
~+
=/ =yaki:clay (~(got by hut.rang) tako)
=/ takos
|- ^- (set [^ship ^desk tako:clay norm:clay path])
?~ p.yaki
~
(~(uni in $(p.yaki t.p.yaki)) ^$(tako i.p.yaki))
|- ^- (set [^ship ^desk tako:clay norm:clay path])
?~ q.yaki
takos
%- ~(uni in $(q.yaki l.q.yaki))
%- ~(uni in $(q.yaki r.q.yaki))
^- (set [^ship ^desk tako:clay norm:clay path])
?. =(lobe q.n.q.yaki)
~
[[ship desk tako (~(gut by tom.dome) tako nor.dome) p.n.q.yaki] ~ ~]
--
^- (list note-arvo)
%+ welp
2022-04-13 07:02:37 +03:00
%+ murn ~(tap in norms)
2022-04-09 07:20:02 +03:00
|= [=ship =desk =tako:clay =norm:clay =path]
2022-04-13 07:02:37 +03:00
?: ?=([~ %|] (~(fit de norm) path))
~
2022-04-09 07:20:02 +03:00
%- (slog leaf+"tomb: {<ship desk path `@uv`tako norm path>}" ~)
?: dry
2022-04-13 07:02:37 +03:00
~
`[%c %tomb %worn ship desk tako (~(put de norm) path %|)]
2022-04-09 07:20:02 +03:00
?: dry
2022-04-13 07:02:37 +03:00
~
2022-04-09 07:20:02 +03:00
[%c %tomb %pick ~]~