urbit/mar/lens/command.hoon
benjamin-tlon d06693dc7e
Add support to lens-command for pill output and optimized base64 encoding. (#1068)
Added support to `lens-command` for outputting a pill. We want this so that we can create (solid and brass) pills from `urb.py`.

This also adds an optimized base64 encoding routine. The previous version of base64 stack overflowed on large inputs, and a tail-recursive version took hours to encode 5mb of data. This one uses the `ripn` jet and only takes a second or two.
2019-02-27 16:12:59 -08:00

63 lines
1.4 KiB
Plaintext

/- lens
|_ com/command:lens
++ grab
|%
++ noun command:lens
++ json
|= jon/^json
^- command:lens
~| jon=jon
%- need
%. jon
=< %- ot :~
source+source
sink+sink
==
=, dejs-soft:format
|%
++ source
^- $-(^^json (unit source:lens))
|= jon/^^json
=+ tuple=%.(jon (ar source))
?^ tuple
`[%tuple u.tuple]
%. jon
%- of :~
data+so
dojo+so
clay+so
url+(su auri:de-purl:html)
api+(su ;~(plug sym ;~(pfix col prn)))
:- %get-api
%- su
;~ plug
sym
;~(pfix col (more net (cook crip (star ;~(less net prn)))))
==
listen-api+(su ;~(plug sym ;~(pfix col sym)))
as+(ot mark+(su sym) next+source ~)
hoon+(ot code+so next+source ~)
==
++ none |=(^^json (some ~))
++ sink
^- $-(^^json (unit sink:lens))
%- of :~
stdout+none
output-file+so
output-pill+so
output-clay+(su (easy /sentinel/path))
url+(su auri:de-purl:html)
to-api+(su ;~(plug sym ;~(pfix col prn)))
:- %send-api
%- su
;~ plug
sym
;~(pfix col (more net (cook crip (star ;~(less net prn)))))
==
command+so
app+(su sym)
==
--
--
--