Extracted %ask generator methods from sur/sole and put them in a core
under lib/sole
Fixed names in existing generators
This commit is contained in:
David Kerschner 2018-10-02 12:26:16 -07:00
parent 9f28fa396e
commit 69b5c6fcb0
12 changed files with 115 additions and 118 deletions

View File

@ -3,15 +3,14 @@
:::: /hoon/curl-hiss/gen
::
/? 310
/- sole
/+ old-zuse
/+ sole, old-zuse
=, old-zuse
=, sole
=, ask:sole
:- %get |= {^ {a/hiss ~} usr/iden}
^- (sole-request (cask httr))
^- (sole-request:sole (cask httr))
?. ?=($get p.q.a)
~| %only-get-requests-supported-in-generators :: XX enforced?
!!
:- *tang
:^ %| `usr `hiss`a
|=(hit/httr (sole-so %httr hit))
|=(hit/httr (output %httr hit))

View File

@ -3,12 +3,11 @@
:::: /hoon/curl/gen
::
/? 310
/- sole
/+ old-zuse
/+ sole, old-zuse
=, old-zuse
=, sole
=, ask:sole
:- %get |= {^ {a/tape ~} ~}
^- (sole-request (cask httr))
%+ sole-at (scan a auri:urlp)
^- (sole-request:sole (cask httr))
%+ curl (scan a auri:urlp)
|= hit/httr
(sole-so %httr hit)
(output %httr hit)

View File

@ -2,29 +2,31 @@
::
:::: /hoon/authority/dns/gen
::
/- dns, sole
=, [dns sole]
/- dns
/+ sole
=, dns
=, ask:sole
:- %ask
|= $: [now=@da eny=@uvJ bec=beak]
[arg=$@(~ [dom=path ~])]
~
==
^- (sole-result [%dns-authority authority])
^- (sole-result:sole [%dns-authority authority])
=- ?~ arg -
(fun.q.q [%& dom.arg])
%+ sole-lo
%+ prompt
[%& %dns-domain "dns domain: "]
%+ sole-go thos:de-purl:html
%+ parse thos:de-purl:html
|= hot=host:eyre
?: ?=(%| -.hot)
~|(%ips-unsupported !!)
%+ sole-lo
%+ prompt
[%& %project "gcloud project: "]
%+ sole-go urs:ab
%+ parse urs:ab
|= project=@ta
%+ sole-lo
%+ prompt
[%& %zone "dns zone: "]
%+ sole-go urs:ab
%+ parse urs:ab
|= zone=@ta
%+ sole-so %dns-authority
%+ output %dns-authority
[p.hot %gcloud project zone]

View File

@ -3,8 +3,7 @@
:::: /hoon/begin/hood/gen
::
/? 310
/- sole
/+ old-zuse
/+ sole, old-zuse
=, old-zuse
::
::::
@ -13,34 +12,34 @@
++ begs {his/@p tic/@p yen/@t ges/gens}
++ scug |*({a/@ b/(pole)} ?~(b ~ ?~(a ~ [-.b $(b +.b, a (dec a))])))
--
=, sole
=, ask:sole
:- %ask
|= $: {now/@da eny/@uvJ bec/beak}
{arg/_(scug *@ *{his/@p tic/@p ~})}
safety/?($off $on)
==
^- (sole-result (cask begs))
^- (sole-result:sole (cask begs))
?. =(safety %off)
%+ sole-yo
%+ print
:- %leaf
"|begin is deprecated, please invoke urbit with -w [name] -t [ticket]"
sole-no
no-result
=- -
%+ sole-lo
%+ prompt
[%& %helm-begin "your urbit: ~"]
%+ sole-go fed:ag
%+ parse fed:ag
|= his/@p
%+ sole-lo
%+ prompt
[%& %helm-ticket "your ticket: ~"]
%+ sole-go fed:ag
%+ parse fed:ag
|= tic/@p
%+ sole-lo
%+ prompt
[%& %helm-entropy "some entropy: "]
%+ sole-go (boss 256 (more gon qit))
%+ parse (boss 256 (more gon qit))
|= yen/@t
=+ ney=(shax yen)
%+ sole-yo `tank`[%leaf "entropy check: {(scow %p `@p`(mug ney))}"]
%+ sole-so %helm-begin
%+ print `tank`[%leaf "entropy check: {(scow %p `@p`(mug ney))}"]
%+ output %helm-begin
:* his
tic
ney

View File

@ -3,32 +3,32 @@
:::: /hoon/init-auth-basic/hood/gen
::
/? 314
/- sole
/+ sole
::
::::
::
=, sole
=, ask:sole
:- %ask
|= $: {now/@da eny/@uvJ bec/beak}
{arg/$@(~ {dom/path ~})}
~
==
^- (sole-result {$write-sec-atom p/host:eyre q/@})
^- (sole-result:sole {$write-sec-atom p/host:eyre q/@})
=- ?~ arg -
(fun.q.q [%& dom.arg])
%+ sole-lo
%+ prompt
[%& %oauth-hostname "api hostname: https://"]
%+ sole-go thos:de-purl:html
%+ parse thos:de-purl:html
|= hot/host:eyre
?: ?=(%| -.hot)
~|(%ips-unsupported !!)
%+ sole-lo
%+ prompt
[%& %auth-user "username: "]
%+ sole-go (boss 256 (star ;~(less col prn)))
%+ parse (boss 256 (star ;~(less col prn)))
|= usr/@t
%+ sole-lo
%+ prompt
[%| %auth-passwd "password: "]
%+ sole-go (boss 256 (star prn))
%+ parse (boss 256 (star prn))
|= pas/@t
%+ sole-so %write-sec-atom :: XX typed pair
%+ output %write-sec-atom :: XX typed pair
[hot (crip (en-base64:mimes:html (rap 3 usr ':' pas ~)))]

View File

@ -3,34 +3,33 @@
:::: /hoon/init-oauth1/hood/gen
::
/? 314
/- sole
/+ old-zuse
/+ sole, old-zuse
=, old-zuse
::
::::
::
=, sole
=, ask:sole
:- %ask
|= $: {now/@da eny/@uvJ bec/beak}
{arg/$@(~ {dom/path ~})}
~
==
^- (sole-result {$write-sec-atom p/host q/@})
^- (sole-result:sole {$write-sec-atom p/host q/@})
=- ?~ arg -
(fun.q.q [%& dom.arg])
%+ sole-lo
%+ prompt
[%& %oauth-hostname "api hostname: https://"]
%+ sole-go thos:urlp
%+ parse thos:urlp
|= hot/host
?: ?=(%| -.hot)
~|(%ips-unsupported !!)
%+ sole-lo
%+ prompt
[%& %oauth-client "consumer key: "]
%+ sole-go (boss 256 (star prn))
%+ parse (boss 256 (star prn))
|= key/@t
%+ sole-lo
%+ prompt
[%& %oauth-secret "consumer secret: "]
%+ sole-go (boss 256 (star prn))
%+ parse (boss 256 (star prn))
|= sec/@t
%+ sole-so %write-sec-atom :: XX typed pair
%+ output %write-sec-atom :: XX typed pair
[hot (of-wain:format key sec ~)]

View File

@ -3,34 +3,33 @@
:::: /hoon/init-oauth2/hood/gen
::
/? 314
/- sole
/+ old-zuse
/+ sole, old-zuse
=, old-zuse
::
::::
::
=, sole
=, ask:sole
:- %ask
|= $: {now/@da eny/@uvJ bec/beak}
{arg/$@(~ {dom/path ~})}
~
==
^- (sole-result {$write-sec-atom p/host:eyre q/@})
^- (sole-result:sole {$write-sec-atom p/host:eyre q/@})
=- ?~ arg -
(fun.q.q [%& dom.arg])
%+ sole-lo
%+ prompt
[%& %oauth-hostname "api hostname: https://"]
%+ sole-go thos:de-purl:html
%+ parse thos:de-purl:html
|= hot/host:eyre
?: ?=(%| -.hot)
~|(%ips-unsupported !!)
%+ sole-lo
%+ prompt
[%& %oauth-client "client id: "]
%+ sole-go (boss 256 (star prn))
%+ parse (boss 256 (star prn))
|= cid/@t
%+ sole-lo
%+ prompt
[%& %oauth-secret "client secret: "]
%+ sole-go (boss 256 (star prn))
%+ parse (boss 256 (star prn))
|= cis/@t
%+ sole-so %write-sec-atom :: XX typed pair
%+ output %write-sec-atom :: XX typed pair
[hot (of-wain:format cid cis ~)]

View File

@ -3,13 +3,12 @@
:::: /hoon/google/init-oauth2/hood/gen
::
/? 314
/- sole
/+ old-zuse
/+ sole, old-zuse
=, old-zuse
::
::::
::
=, sole
=, ask:sole
=, html
=, format
:- %ask
@ -17,17 +16,17 @@
{arg/$@(~ {jon/json ~})}
~
==
^- (sole-result {$write-sec-atom p/host:eyre q/@})
%+ sole-yo leaf+"Accepting credentials for https://*.googleapis.com"
^- (sole-result:sole {$write-sec-atom p/host:eyre q/@})
%+ print leaf+"Accepting credentials for https://*.googleapis.com"
=+ hot=[%& /com/googleapis]
=- ?~ arg -
(fun.q.q jon.arg)
%+ sole-lo
%+ prompt
[%& %oauth-json "json credentials: "]
%+ sole-go apex:de-json
%+ parse apex:de-json
|= jon/json
=+ ~| bad-json+jon
=- `{cid/@t cis/@t}`(need (rep jon))
rep=(ot web+(ot 'client_id'^so 'client_secret'^so ~) ~):dejs-soft:format
%+ sole-so %write-sec-atom :: XX typed pair
%+ output %write-sec-atom :: XX typed pair
[hot (of-wain:format cid cis ~)]

View File

@ -3,10 +3,9 @@
:::: /hoon/moon/gen
::
/? 310
/- sole
/+ old-zuse
/+ sole, old-zuse
=, old-zuse
=, sole
=, ask:sole
::
::::
::
@ -17,9 +16,9 @@
==
=/ ran (clan p.bec)
?: ?=({?($earl $pawn)} ran)
%- sole-so
%- output
:- %tang :_ ~
leaf+"can't create a moon from a {?:(?=($earl ran) "moon" "comet")}"
=/ mon (mix (lsh 5 1 (end 5 1 eny)) p.bec)
=/ tic .^(@ /a/(scot %p p.bec)/tick/(scot %da now)/(scot %p mon))
(sole-so [%tang leaf+"ticket: {<`@p`tic>}" leaf+"moon: {<`@p`mon>}" ~])
(output [%tang leaf+"ticket: {<`@p`tic>}" leaf+"moon: {<`@p`mon>}" ~])

View File

@ -4,24 +4,23 @@
::
/? 310
:: Input twitter keys
/- sole
/+ old-zuse
/+ sole, old-zuse
=, old-zuse
::
=+ cryp=crub
=+ [sole]
=, ask:sole
:- %ask
|= $: {now/@da eny/@uvJ bec/beak}
{{who/ship ~} ~}
==
^- (sole-result (cask tang))
%+ sole-yo leaf+"generating carrier {(scow %p who)} (#{(scow %ud who)})"
%+ sole-lo [%| %pope-pass "passphrase: "]
%+ sole-go (boss 256 (star prn))
^- (sole-result:sole (cask tang))
%+ print leaf+"generating carrier {(scow %p who)} (#{(scow %ud who)})"
%+ prompt [%| %pope-pass "passphrase: "]
%+ parse (boss 256 (star prn))
|= fra/@t
=+ bur=(shaz (add who (shaz fra)))
=+ arc=(pit:nu:cryp 512 bur)
%+ sole-so %tang
%+ output %tang
:~ leaf+"generator: {(scow %uw bur)}"
leaf+"fingerprint: {(scow %uw fig:ex:arc)}"
==

View File

@ -138,4 +138,36 @@
=+ dat=(transmute [%mor leg] [%ins pos `@c`0])
?> ?=($ins -.dat)
p.dat
++ ask
|%
++ output :: construct result
|* pro/* ::
[p=*(list tank) q=[%& p=[~ u=pro]]] ::
:: ::
++ print :: add output tank
|* {tan/tank res/(sole-result)} ::
?@ res res ::
[p=[i=tan t=p.res] q=q.res] ::
:: ::
++ prompt :: construct prompt
|* {pom/sole-prompt mor/(sole-dialog)} ::
[p=*(list tank) q=[%| p=pom q=mor]] ::
:: ::
++ curl :: fetch url
=| usr/knot ::
|* {pul/_purl:eyre fun/$-(httr:eyre *)} ::
:- p=*(list tank) ::
q=[%| p=`usr q=[pul %get ~ ~] r=fun] ::
:: ::
++ no-result :: empty result
[p=*(list tank) q=[%& ~]] ::
:: ::
++ parse :: parse by rule
|* {sef/rule fun/$-(* *)} ::
|= txt/sole-input ::
=+ vex=(sef [0 0] txt) ::
?: |(!=((lent txt) q.p.vex) ?=($~ q.vex)) ::
q.p.vex ::
(fun p.u.q.vex) ::
--
--

View File

@ -70,7 +70,7 @@
%+ each (unit out) :: ~ is abort
(pair sole-prompt (sole-dialog out)) :: ask and continue
:: ::
++ sole-request :: scraper result
++ sole-request :: scraper result
|* out/$-(* *) :: output structure
%+ pair (list tank) ::
%+ each (unit out) :: ~ is abort
@ -91,33 +91,4 @@
{{now/@da eny/@uvJ bek/beak} {,+<- ,+<+}} ::
:: ::
:: ::
++ sole-so :: construct result
|* pro/* ::
[p=*(list tank) q=[%& p=[~ u=pro]]] ::
:: ::
++ sole-yo :: add output tank
|* {tan/tank res/(sole-result)} ::
?@ res res ::
[p=[i=tan t=p.res] q=q.res] ::
:: ::
++ sole-lo :: construct prompt
|* {pom/sole-prompt mor/(sole-dialog)} ::
[p=*(list tank) q=[%| p=pom q=mor]] ::
:: ::
++ sole-at :: fetch url
=| usr/knot ::
|* {pul/_purl:eyre fun/$-(httr:eyre *)} ::
:- p=*(list tank) ::
q=[%| p=`usr q=[pul %get ~ ~] r=fun] ::
:: ::
++ sole-no :: empty result
[p=*(list tank) q=[%& ~]] ::
:: ::
++ sole-go :: parse by rule
|* {sef/rule fun/$-(* *)} ::
|= txt/sole-input ::
=+ vex=(sef [0 0] txt) ::
?: |(!=((lent txt) q.p.vex) ?=(~ q.vex)) ::
q.p.vex ::
(fun p.u.q.vex) ::
--