herb: add cancel command

This commit is contained in:
ixv 2021-05-29 12:53:23 -07:00
parent 457904368b
commit 3a14176934
5 changed files with 16 additions and 3 deletions

View File

@ -1162,6 +1162,7 @@
%import !! %import !!
%export-all !! %export-all !!
%import-all !! %import-all !!
%cancel !!
%as %as
:* %as mar.source.com :* %as mar.source.com
$(num +(num), source.com next.source.com) $(num +(num), source.com next.source.com)

View File

@ -1,5 +1,5 @@
/- lens, *sole /- lens, *sole
/+ *server, default-agent /+ *server, default-agent, dbug
/= lens-mark /mar/lens/command :: TODO: ask clay to build a $tube /= lens-mark /mar/lens/command :: TODO: ask clay to build a $tube
=, format =, format
|% |%
@ -35,6 +35,8 @@
-- --
:: ::
=| =state =| =state
%- agent:dbug
^- agent:gall
|_ =bowl:gall |_ =bowl:gall
+* this . +* this .
def ~(. (default-agent this %|) bowl) def ~(. (default-agent this %|) bowl)
@ -56,8 +58,6 @@
?. ?=(%handle-http-request mark) ?. ?=(%handle-http-request mark)
(on-poke:def mark vase) (on-poke:def mark vase)
=+ !<([eyre-id=@ta =inbound-request:eyre] vase) =+ !<([eyre-id=@ta =inbound-request:eyre] vase)
?> ?=(~ job.state)
::
=/ request-line (parse-request-line url.request.inbound-request) =/ request-line (parse-request-line url.request.inbound-request)
=/ site (flop site.request-line) =/ site (flop site.request-line)
:: ::
@ -76,6 +76,13 @@
=/ com=command:lens =/ com=command:lens
(json:grab:lens-mark jon) (json:grab:lens-mark jon)
:: ::
?: ?=(%cancel -.source.com)
~& %lens-cancel
:_ this(job.state ~)
(give-simple-payload:app eyre-id (json-response:gen [%s 'cancelled']))
::
?> ?=(~ job.state)
::
?+ -.source.com ?+ -.source.com
:_ this(job.state (some [eyre-id com])) :_ this(job.state (some [eyre-id com]))
[%pass /sole %agent [our.bowl %dojo] %watch /sole/[eyre-id]]~ [%pass /sole %agent [our.bowl %dojo] %watch /sole/[eyre-id]]~

View File

@ -46,6 +46,7 @@
import-all+(ot base64-jam+so ~) import-all+(ot base64-jam+so ~)
as+(ot mark+(su sym) next+source ~) as+(ot mark+(su sym) next+source ~)
hoon+(ot code+so next+source ~) hoon+(ot code+so next+source ~)
cancel+none
== ==
++ none |=(^^json (some ~)) ++ none |=(^^json (some ~))
++ sink ++ sink

View File

@ -19,6 +19,7 @@
[%import app=@t base64-jam=@t] [%import app=@t base64-jam=@t]
[%export-all ~] [%export-all ~]
[%import-all base64-jam=@t] [%import-all base64-jam=@t]
[%cancel ~]
== ==
++ sink ++ sink
$% [%stdout ~] $% [%stdout ~]

View File

@ -403,6 +403,9 @@ parser.add_argument('--close',
nargs=0, nargs=0,
help='stop tuple', help='stop tuple',
action=closeAction) action=closeAction)
parser.add_argument('--cancel', const={'cancel': None},
help='cancels active lens command',
action='store_const', dest='source')
sinks = parser.add_mutually_exclusive_group() sinks = parser.add_mutually_exclusive_group()
sinks.add_argument('-s', '--stdout', const={'stdout': None}, sinks.add_argument('-s', '--stdout', const={'stdout': None},