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 !!
%export-all !!
%import-all !!
%cancel !!
%as
:* %as mar.source.com
$(num +(num), source.com next.source.com)

View File

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

View File

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

View File

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

View File

@ -403,6 +403,9 @@ parser.add_argument('--close',
nargs=0,
help='stop tuple',
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.add_argument('-s', '--stdout', const={'stdout': None},