cli utils, yet untyped

This commit is contained in:
Anton Dyudin 2015-05-27 19:46:58 -07:00
parent f2e0911933
commit 1f43185e71
12 changed files with 159 additions and 17 deletions

View File

@ -450,7 +450,8 @@
dy-amok(var (~(put by var) p.mad (~(got by rez) p.q.mad)))
::
%show
(dy-rash %tan (sell q:(~(got by rez) p.p.mad)) ~)
=+ cay=(~(got by rez) p.p.mad)
(dy-rash %tan ?+(p.cay [(sell q.cay)]~ %tang ;;(tang q.q.cay)))
==
::
++ dy-edit :: handle edit

View File

@ -1,4 +1,4 @@
:: :: ::
:: :: ::
:::: /hook/core/hood/ape :: ::
:: :: ::
/? 314 :: zuse version
@ -110,6 +110,17 @@
|= [from dill-belt]
(ably (poke-dill-belt:(drum-work [hid +<-] (able %drum)) +<+))
::
++ from-kiln
=- [wrap=- *kiln-work]
|* fun=_=>(*kiln-work |=(* abet))
|= [from _+<.fun]
=. +>.fun (kiln-work [hid +<-] (able %kiln))
(ably (fun +<+))
::
++ poke-kiln-cp (wrap poke-cp):from-kiln
++ poke-kiln-rm (wrap poke-rm):from-kiln
++ poke-kiln-mv (wrap poke-mv):from-kiln
::
++ poke-will ::
|= [from (unit will)]
(ably (poke-will:(helm-work [hid +<-] (able %helm)) +<+))

View File

@ -367,7 +367,7 @@
++ mo-cook :: take in /use
|= [pax=path hin=(hypo sign-arvo)]
^+ +>
?. ?=([@ @ ?(%inn %out %enn) *] pax)
?. ?=([@ @ ?(%inn %out %cay) *] pax)
~& [%mo-cook-bad-pax pax]
!!
=+ dap=`@tas`i.pax
@ -376,11 +376,11 @@
=+ vax=(slot 3 `vase`hin)
?- i.t.t.pax
%inn ap-abet:(ap-pour:pap t.t.t.pax (slot 3 `vase`hin))
%enn ?. ?=([%e %sigh *] q.hin)
%cay ?. ?=([%e %sigh *] q.hin)
~& [%mo-cook-weird q.hin]
~& [%mo-cook-weird-path pax]
+>.$
ap-abet:(ap-sigh:pap t.t.t.pax +>.q.hin)
ap-abet:(ap-purr:pap +<.q.hin t.t.t.pax +>.q.hin)
::
%out ?. ?=([%g %unto *] q.hin)
~& [%mo-cook-weird q.hin]
@ -685,7 +685,7 @@
?. &(?=(^ pux) (levy u.pux (sane %ta)))
[%| (ap-suck "move: malformed path")]
:^ %& sto %pass
:- [(scot %p q.q.pry) %enn u.pux]
:- [(scot %p q.q.pry) %cay u.pux]
[%hiss q.q.vax [p.q.gaw (slot 3 (spec gaw))]]
::
++ ap-move-mess :: extract path, target
@ -857,13 +857,13 @@
?^ cam (ap-lame -.q.vax u.cam)
+>.$
::
++ ap-sigh :: http response
|= [pax=path cag=cage]
++ ap-purr :: unwrap take
|= [wha=term pax=path cag=cage]
^+ +>
=. q.cag (spec q.cag)
=+ cug=(ap-find [%sigh p.cag pax])
=+ cug=(ap-find [wha p.cag pax])
?~ cug
(ap-lame %sigh (ap-suck "sigh: no {<`path`[p.cag pax]>}"))
(ap-lame wha (ap-suck "{(trip wha)}: no {<`path`[p.cag pax]>}"))
=+ ^= arg ^- vase
%- slop
?: =(0 p.u.cug)
@ -1027,7 +1027,6 @@
%merg `%c
%plug `%c
%them `%e
%hiss `%e
%want `%a
==
--

28
base/cat/cat/gate.hook Normal file
View File

@ -0,0 +1,28 @@
:: ConCATenate file listings
::
:::: /hook/gate/cat/cat
::
// /%%%/ls/subdir
// /%%/pretty
!:
::::
::
|= [^ [arg=(list path)] ~]
=- tang/(zing -)
%+ turn arg
|= pax=path
^- tang
=+ ark=;;(arch .^(%cy pax))
?^ q.ark
[leaf/(spud pax) (pretty-file .^(%cx pax))]
?- r.ark :: handle ambiguity
~
[rose/[" " `~]^~[leaf/"~" (smyt pax)]]~
[[@t ~] ~ ~]
$(pax (welp pax /[p.n.r.ark]))
*
=- [palm/[": " ``~]^-]~
:~ rose/[" " `~]^~[leaf/"*" (smyt pax)]
`tank`(subdir pax r.ark)
==
==

25
base/cat/cat/pretty.hoon Normal file
View File

@ -0,0 +1,25 @@
!:
|%
++ pretty-noun
|= pri=* ^- tank
?~ pri
leaf/"~"
?@ pri
leaf/?:(((sane %tas) pri) <`@tas`pri> <pri>)
=< rose/[" " ?:(- "~[" "[") "]"]^+
|- ^- [? (list tank)]
?~ +.pri
[& ^$(pri -.pri) ~]
?@ +.pri
[| ^$(pri -.pri) ^$(pri +.pri) ~]
[+< - +>]:[^$(pri -.pri) $(pri +.pri)]
::
++ vale-cord |=(a=cord `?`(levy (trip a) |=(b=@ |((gte b 32) =(10 b)))))
::
++ pretty-file
=+ wain-to-tang=|=(a=wain (turn a |=(b=cord leaf/(trip b))))
|= fyl=* ^- tang
=+ `(unit wain)`?@(fyl `(lore fyl) ((soft wain) fyl))
?^ - (wain-to-tang u)
[(pretty-noun fyl)]~
--

View File

@ -0,0 +1 @@
|=([^ [input=path output=path ~] ~] kiln-mv/[input output])

View File

@ -0,0 +1 @@
|=([^ [input=path output=path ~] ~] kiln-cp/[input output])

View File

@ -0,0 +1 @@
|=([^ [input=path ~] ~] kiln-rm/input)

11
base/cat/ls/gate.hook Normal file
View File

@ -0,0 +1,11 @@
:: LiSt directory subnodes
::
:::: /hook/gate/ls/cat
::
// /%%/subdir
!:
::::
::
|= [^ [arg=path ~] ~]
=+ lon=((hard arch) .^(%cy arg))
tang/[?~(r.lon leaf/"~" (subdir arg r.lon))]~

20
base/cat/ls/subdir.hoon Normal file
View File

@ -0,0 +1,20 @@
|%
++ subdir
|= [pax=path des=(map ,@t ,~)]
^- tank
:+ %rose [" " `~]
%+ turn (sort (~(tap by des)) aor)
|= [kid=@ta ~]
=+ paf=`path`/[kid]
=- :+ %rose ["/" ~ ?:(dir "/" ~)]
(turn paf |=(a=span leaf/(trip a)))
|- ^- [dir=? paf=path]
=+ arf=;;(arch .^(%cy (weld pax paf)))
?^ q.arf
[| paf]
?~ r.arf
[& paf] :: !!
?. ?=([^ ~ ~] r.arf)
[& paf]
$(paf (welp paf /[p.n.r.arf]))
--

20
base/cat/tree/gate.hook Normal file
View File

@ -0,0 +1,20 @@
:: Tree view recursive directory contents
::
:::: /hook/gate/tree/cat
::
!:
::::
::
|= [^ [pax=path fla=$|(~ [%full ~])] ~]
=+ len=(lent pax)
=+ rend=?^(fla dank:ut |=(a=path (dank:ut (slag len a))))
:- %tang
|- ^- tang
=+ ark=;;(arch .^(cy/pax))
=- ?~ q.ark -
[(rend pax) -]
%- zing
%+ turn
(sort (~(tap by r.ark)) aor)
|= [a=@t ~]
^$(pax (welp pax /[a]))

View File

@ -2,10 +2,17 @@
:::: /hook/core/kiln/lib :: ::
:: :: ::
/? 310 :: version
:: /+ mean XX
:: :: ::
:::: :: ::
:: :: ::
|% :: ::
++ mean
|= a=tang
?~ a !!
~> %mean.|.(i.a)
$(a t.a)
::
++ kiln-part ,[%kiln %0 kiln-pith] :: kiln state
++ kiln-pith ::
$: rem=(map desk kiln-desk) ::
@ -35,6 +42,8 @@
sud=desk ::
gim=?(%auto germ) ::
== ::
++ hood-cp [input=path output=path] ::
++ hood-mv [input=path output=path]
-- ::
:: :: ::
:::: :: ::
@ -81,6 +90,25 @@
|= hood-merge
abet:abet:(merge:(work syd) ali sud gim)
::
++ do-info
|= [mez=tape pax=path tor=toro]
=+ syd=q:(need (tome pax))
=- abet:abet:(spam:(work syd) leaf/mez ~)
(emit %info /kiln our tor)
++ poke-rm |=(a=path (do-info "removed" a (fray a)))
++ poke-cp
|= [input=path output=path]
%^ do-info "copied" input
?> =(-:(flop input) -:(flop output))
(foal output -:(flop input) %noun .^(%cx input)) :: XX type
::
++ poke-mv
|= [input=path output=path]
%^ do-info "moved" input
?> =(-:(flop input) -:(flop output))
%+ furl (fray output)
(foal output -:(flop input) %noun .^(%cx input))
::
++ take |=(way=wire ?>(?=([@ ~] way) (work i.way))) :: general handler
++ take-mere ::
|= [way=wire are=(each (set path) (pair term tang))]
@ -116,12 +144,8 @@
!!
::
++ ford-fail
|= tan=tang
~| %ford-fail
|-
?~ tan !!
~> %mean.|.(i.tan) :: interpolate into stack trace
$(tan t.tan)
|=(tan=tang ~|(%ford-fail (mean tan)))
::
++ unwrap-tang
|* res=(each ,* tang)