cleanup, docs
This commit is contained in:
@@ -1,10 +1,8 @@
|
||||
:title
|
||||
cli_input
|
||||
|
||||
:sig
|
||||
DValue cli_input(Request& context)
|
||||
|
||||
:see
|
||||
>ob
|
||||
>1_CLI
|
||||
>json_decode
|
||||
>DValue
|
||||
@@ -22,20 +20,9 @@ Later sources override earlier ones, so a JSON body can override a query or form
|
||||
|
||||
If the JSON body is a scalar or array instead of an object, the decoded value is stored under `input["_"]`.
|
||||
|
||||
```cpp
|
||||
CLI(Request& context)
|
||||
{
|
||||
DValue input = cli_input(context);
|
||||
String action = first(input["action"].to_string(), "help");
|
||||
|
||||
if(action == "echo")
|
||||
print(input["message"].to_string(), "\n");
|
||||
}
|
||||
```
|
||||
|
||||
Convenience script usage:
|
||||
|
||||
```sh
|
||||
scripts/uce-cli /tests/cli.uce action=echo message=hello
|
||||
scripts/uce-cli --json '{"action":"echo","message":"hello"}' /tests/cli.uce
|
||||
```
|
||||
|
||||
:example
|
||||
print("cli_input example\n");
|
||||
|
||||
Reference in New Issue
Block a user