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

65 lines
1.8 KiB
Plaintext
Raw Normal View History

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