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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -3,10 +3,9 @@
:::: /hoon/moon/gen :::: /hoon/moon/gen
:: ::
/? 310 /? 310
/- sole /+ sole, old-zuse
/+ old-zuse
=, old-zuse =, old-zuse
=, sole =, ask:sole
:: ::
:::: ::::
:: ::
@ -17,9 +16,9 @@
== ==
=/ ran (clan p.bec) =/ ran (clan p.bec)
?: ?=({?($earl $pawn)} ran) ?: ?=({?($earl $pawn)} ran)
%- sole-so %- output
:- %tang :_ ~ :- %tang :_ ~
leaf+"can't create a moon from a {?:(?=($earl ran) "moon" "comet")}" leaf+"can't create a moon from a {?:(?=($earl ran) "moon" "comet")}"
=/ mon (mix (lsh 5 1 (end 5 1 eny)) p.bec) =/ mon (mix (lsh 5 1 (end 5 1 eny)) p.bec)
=/ tic .^(@ /a/(scot %p p.bec)/tick/(scot %da now)/(scot %p mon)) =/ 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 /? 310
:: Input twitter keys :: Input twitter keys
/- sole /+ sole, old-zuse
/+ old-zuse
=, old-zuse =, old-zuse
:: ::
=+ cryp=crub =+ cryp=crub
=+ [sole] =, ask:sole
:- %ask :- %ask
|= $: {now/@da eny/@uvJ bec/beak} |= $: {now/@da eny/@uvJ bec/beak}
{{who/ship ~} ~} {{who/ship ~} ~}
== ==
^- (sole-result (cask tang)) ^- (sole-result:sole (cask tang))
%+ sole-yo leaf+"generating carrier {(scow %p who)} (#{(scow %ud who)})" %+ print leaf+"generating carrier {(scow %p who)} (#{(scow %ud who)})"
%+ sole-lo [%| %pope-pass "passphrase: "] %+ prompt [%| %pope-pass "passphrase: "]
%+ sole-go (boss 256 (star prn)) %+ parse (boss 256 (star prn))
|= fra/@t |= fra/@t
=+ bur=(shaz (add who (shaz fra))) =+ bur=(shaz (add who (shaz fra)))
=+ arc=(pit:nu:cryp 512 bur) =+ arc=(pit:nu:cryp 512 bur)
%+ sole-so %tang %+ output %tang
:~ leaf+"generator: {(scow %uw bur)}" :~ leaf+"generator: {(scow %uw bur)}"
leaf+"fingerprint: {(scow %uw fig:ex:arc)}" leaf+"fingerprint: {(scow %uw fig:ex:arc)}"
== ==

View File

@ -138,4 +138,36 @@
=+ dat=(transmute [%mor leg] [%ins pos `@c`0]) =+ dat=(transmute [%mor leg] [%ins pos `@c`0])
?> ?=($ins -.dat) ?> ?=($ins -.dat)
p.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 %+ each (unit out) :: ~ is abort
(pair sole-prompt (sole-dialog out)) :: ask and continue (pair sole-prompt (sole-dialog out)) :: ask and continue
:: :: :: ::
++ sole-request :: scraper result ++ sole-request :: scraper result
|* out/$-(* *) :: output structure |* out/$-(* *) :: output structure
%+ pair (list tank) :: %+ pair (list tank) ::
%+ each (unit out) :: ~ is abort %+ each (unit out) :: ~ is abort
@ -91,33 +91,4 @@
{{now/@da eny/@uvJ bek/beak} {,+<- ,+<+}} :: {{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) ::
-- --