urbit/pkg/arvo/lib/verb.hoon

93 lines
2.1 KiB
Plaintext
Raw Normal View History

2019-11-09 02:18:29 +03:00
:: Print what your agent is doing.
::
2019-11-19 07:36:21 +03:00
|= [loud=? =agent:gall]
=| bowl-print=_|
2019-11-19 07:36:21 +03:00
^- agent:gall
|^
2019-11-19 07:36:21 +03:00
|_ =bowl:gall
2019-11-09 02:18:29 +03:00
+* this .
ag ~(. agent bowl)
::
++ on-init
2019-11-19 07:36:21 +03:00
^- (quip card:agent:gall agent:gall)
%- (print bowl "{<dap.bowl>}: on-init")
2019-11-09 02:18:29 +03:00
=^ cards agent on-init:ag
[cards this]
::
++ on-save
^- vase
%- (print bowl "{<dap.bowl>}: on-save")
2019-11-09 02:18:29 +03:00
on-save:ag
::
++ on-load
|= old-state=vase
2019-11-19 07:36:21 +03:00
^- (quip card:agent:gall agent:gall)
%- (print bowl "{<dap.bowl>}: on-load")
2019-11-09 02:18:29 +03:00
=^ cards agent (on-load:ag old-state)
[cards this]
::
++ on-poke
|= [=mark =vase]
2019-11-19 07:36:21 +03:00
^- (quip card:agent:gall agent:gall)
%- (print bowl "{<dap.bowl>}: on-poke with mark {<mark>}")
2019-11-09 06:32:21 +03:00
?: ?=(%verb mark)
?- !<(?(%loud %bowl) vase)
%loud `this(loud !loud)
%bowl `this(bowl-print !bowl-print)
==
2019-11-09 02:18:29 +03:00
=^ cards agent (on-poke:ag mark vase)
[cards this]
::
++ on-watch
|= =path
2019-11-19 07:36:21 +03:00
^- (quip card:agent:gall agent:gall)
%- (print bowl "{<dap.bowl>}: on-watch on path {<path>}")
2019-11-09 02:18:29 +03:00
=^ cards agent (on-watch:ag path)
[cards this]
::
++ on-leave
|= =path
2019-11-19 07:36:21 +03:00
^- (quip card:agent:gall agent:gall)
%- (print bowl "{<dap.bowl>}: on-leave on path {<path>}")
2019-11-09 02:18:29 +03:00
=^ cards agent (on-leave:ag path)
[cards this]
::
++ on-peek
|= =path
^- (unit (unit cage))
%- (print bowl "{<dap.bowl>}: on-peek on path {<path>}")
2019-11-09 02:18:29 +03:00
(on-peek:ag path)
::
++ on-agent
2019-11-19 07:36:21 +03:00
|= [=wire =sign:agent:gall]
^- (quip card:agent:gall agent:gall)
%- (print bowl "{<dap.bowl>}: on-agent on wire {<wire>}, {<-.sign>}")
2019-11-09 06:32:21 +03:00
=^ cards agent (on-agent:ag wire sign)
2019-11-09 02:18:29 +03:00
[cards this]
::
++ on-arvo
|= [=wire =sign-arvo]
2019-11-19 07:36:21 +03:00
^- (quip card:agent:gall agent:gall)
%- (print bowl "{<dap.bowl>}: on-arvo on wire {<wire>}, {<[- +<]:sign-arvo>}")
2019-11-09 02:18:29 +03:00
=^ cards agent (on-arvo:ag wire sign-arvo)
[cards this]
::
++ on-fail
|= [=term =tang]
2019-11-19 07:36:21 +03:00
^- (quip card:agent:gall agent:gall)
%- (print bowl "{<dap.bowl>}: on-fail with term {<term>}")
2019-11-09 02:18:29 +03:00
=^ cards agent (on-fail:ag term tang)
[cards this]
--
::
++ print
|= [=bowl:gall =tape]
^+ same
=? . bowl-print
%- (slog >bowl< ~)
.
?. loud same
%- (slog leaf+tape ~)
same
--