Open flaki opened 2 years ago
I want to work on this.
The task is to amend the existing subo create runnable
command, so it accepts a flag.
The flag is --handler
, it should have an optional argument, and it should NOT have a shorthand.
The expectations are:
subo create runnable doSomething
This works as expected, creates a directory named doSomething
. This is how the current command works. This should not change.
subo create runnable doSomething --handler
Creates the directory and necessary files in the doSomething
directory. On top of that, it ALSO modifies the root level Directive.yaml
file by adding a new entry to the handlers
array for a type request, method GET, resource /doSomething
, ie the same as the runnable name with a /
prepended.
subo create runnable doSomthing --handler /endpoint
Creates the directory and necessary files in the doSomething
directory.
On top that, it also modifies the root level Directive.yaml
file by adding a new entry to the handlers
array for type: request
, method: GET
, and resource: /endpoint
; the same as the argument to the --handler
flag.
One way this can be solved is to invoke the subo create handler
command from within the running create runnable
command and let that take care of manipulating the Directive.yaml
file.
Another way to do it is to parse the existing yaml file into a struct, add the required handler to the struct, and then write that struct into a yaml file replacing the entire contents of it. There's code on how to do this in the create handler
command.
Currently
subo create runnable
doesn't touch the Directive at all.In certain situations it might be useful to append the newly created runnable to the Directive and expose it as a handler straight away. This is a functionality that is being added as #134 as a separate command -- but it might be that it would make sense also as a flag on
create runnable
.This flag, say
subo create runnable X --handler
would create the runnableX
and append it to the directive as a handler/X
. Alternatively if specified as... --handler foo
, that would set the handler to/foo
instead.The equivalent currently via shell is