Compare commits
6 Commits
2b18ebf314
...
v1.1.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
d820bc2f23
|
|||
|
b458fc1f99
|
|||
|
0771c142fe
|
|||
|
742632a931
|
|||
|
2221828763
|
|||
|
c2a00511c0
|
@@ -14,7 +14,7 @@ endif ("${CMAKE_C_COMPILER_ID}" MATCHES "GNU" OR CMAKE_COMPILER_IS_GNUCC)
|
|||||||
|
|
||||||
# Version
|
# Version
|
||||||
set (project_VERSION_MAJOR "1")
|
set (project_VERSION_MAJOR "1")
|
||||||
set (project_VERSION_MINOR "0")
|
set (project_VERSION_MINOR "1")
|
||||||
set (project_VERSION_PATCH "0")
|
set (project_VERSION_PATCH "0")
|
||||||
|
|
||||||
set (project_VERSION "${project_VERSION_MAJOR}")
|
set (project_VERSION "${project_VERSION_MAJOR}")
|
||||||
|
|||||||
11
NEWS
11
NEWS
@@ -1,3 +1,14 @@
|
|||||||
|
1.1.0 (2020-10-13)
|
||||||
|
|
||||||
|
* Add method name tab completion using OpenRPC information
|
||||||
|
|
||||||
|
* Bind M-Enter to insert a newline into the command line
|
||||||
|
|
||||||
|
* json-rpc-test-server: fix a memory leak and request URI parsing
|
||||||
|
|
||||||
|
* Miscellaneous bug fixes
|
||||||
|
|
||||||
|
|
||||||
1.0.0 (2020-09-05)
|
1.0.0 (2020-09-05)
|
||||||
|
|
||||||
* Initial release
|
* Initial release
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ you get the following niceties:
|
|||||||
results in your favourite editor or redirect them to a file
|
results in your favourite editor or redirect them to a file
|
||||||
- ability to edit the input line in your favourite editor as well with Alt+E
|
- ability to edit the input line in your favourite editor as well with Alt+E
|
||||||
- WebSockets (RFC 6455) can also be used as a transport rather than HTTP
|
- WebSockets (RFC 6455) can also be used as a transport rather than HTTP
|
||||||
|
- support for method name tab completion using OpenRPC discovery
|
||||||
|
|
||||||
Documentation
|
Documentation
|
||||||
-------------
|
-------------
|
||||||
|
|||||||
Submodule http-parser updated: 5d414fcb4b...ec8b5ee63f
@@ -76,6 +76,10 @@ Protocol
|
|||||||
*-o* _ORIGIN_, *--origin*=_ORIGIN_::
|
*-o* _ORIGIN_, *--origin*=_ORIGIN_::
|
||||||
Set the HTTP Origin header to _ORIGIN_. Some servers may need this.
|
Set the HTTP Origin header to _ORIGIN_. Some servers may need this.
|
||||||
|
|
||||||
|
*-O*, *--openrpc*::
|
||||||
|
Call "rpc.discover" upon start-up in order to pull in OpenRPC data for
|
||||||
|
tab completion of method names.
|
||||||
|
|
||||||
Program information
|
Program information
|
||||||
~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~
|
||||||
*-h*, *--help*::
|
*-h*, *--help*::
|
||||||
|
|||||||
@@ -643,6 +643,15 @@ input_el_on_run_editor (EditLine *editline, int key)
|
|||||||
return CC_NORM;
|
return CC_NORM;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static unsigned char
|
||||||
|
input_el_on_newline_insert (EditLine *editline, int key)
|
||||||
|
{
|
||||||
|
(void) key;
|
||||||
|
|
||||||
|
el_insertstr (editline, "\n");
|
||||||
|
return CC_REFRESH;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
input_el_install_prompt (struct input_el *self)
|
input_el_install_prompt (struct input_el *self)
|
||||||
{
|
{
|
||||||
@@ -671,19 +680,17 @@ input_el_start (struct input *input, const char *program_name)
|
|||||||
// Just what are you doing?
|
// Just what are you doing?
|
||||||
el_set (self->editline, EL_BIND, "^u", "vi-kill-line-prev", NULL);
|
el_set (self->editline, EL_BIND, "^u", "vi-kill-line-prev", NULL);
|
||||||
|
|
||||||
// It's probably better to handle this ourselves
|
// It's probably better to handle these ourselves
|
||||||
el_set (self->editline, EL_ADDFN,
|
el_set (self->editline, EL_ADDFN,
|
||||||
"send-line", "Send line", input_el_on_return);
|
"send-line", "Send line", input_el_on_return);
|
||||||
el_set (self->editline, EL_BIND, "\n", "send-line", NULL);
|
el_set (self->editline, EL_BIND, "\n", "send-line", NULL);
|
||||||
|
|
||||||
// It's probably better to handle this ourselves
|
|
||||||
el_set (self->editline, EL_ADDFN,
|
el_set (self->editline, EL_ADDFN,
|
||||||
"run-editor", "Run editor to edit line", input_el_on_run_editor);
|
"run-editor", "Run editor to edit line", input_el_on_run_editor);
|
||||||
el_set (self->editline, EL_BIND, "M-e", "run-editor", NULL);
|
el_set (self->editline, EL_BIND, "M-e", "run-editor", NULL);
|
||||||
|
|
||||||
el_set (self->editline, EL_ADDFN,
|
el_set (self->editline, EL_ADDFN,
|
||||||
"complete", "Complete word", input_el_on_complete);
|
"newline-insert", "Insert a newline", input_el_on_newline_insert);
|
||||||
el_set (self->editline, EL_BIND, "\t", "complete", NULL);
|
el_set (self->editline, EL_BIND, "M-\n", "newline-insert", NULL);
|
||||||
|
|
||||||
// Source the user's defaults file
|
// Source the user's defaults file
|
||||||
el_source (self->editline, NULL);
|
el_source (self->editline, NULL);
|
||||||
@@ -3225,24 +3232,16 @@ fail:
|
|||||||
// --- OpenRPC information extraction ------------------------------------------
|
// --- OpenRPC information extraction ------------------------------------------
|
||||||
|
|
||||||
static void
|
static void
|
||||||
init_openrpc (struct app_context *ctx)
|
parse_rpc_discover (struct app_context *ctx, struct str *buf, struct error **e)
|
||||||
{
|
{
|
||||||
if (!ctx->openrpc)
|
|
||||||
return;
|
|
||||||
|
|
||||||
json_t *id = json_integer (ctx->next_id++);
|
|
||||||
struct str buf = str_make ();
|
|
||||||
struct error *e = json_rpc_call_raw (ctx, "rpc.discover", id, NULL, &buf);
|
|
||||||
json_decref (id);
|
|
||||||
|
|
||||||
// Just optimistically punch through, I don't have time for this shit
|
// Just optimistically punch through, I don't have time for this shit
|
||||||
json_error_t error;
|
json_error_t error;
|
||||||
json_t *response = NULL, *result = NULL, *value = NULL;
|
json_t *response = NULL, *result = NULL, *value = NULL;
|
||||||
if (!e && !(response = json_loadb (buf.str, buf.len, 0, &error)))
|
if (!(response = json_loadb (buf->str, buf->len, 0, &error)))
|
||||||
error_set (&e, "parse failure: %s", error.text);
|
error_set (e, "parse failure: %s", error.text);
|
||||||
else if (!(result = json_object_get (response, "result"))
|
else if (!(result = json_object_get (response, "result"))
|
||||||
|| !(result = json_object_get (result, "methods")))
|
|| !(result = json_object_get (result, "methods")))
|
||||||
error_set (&e, "unsupported");
|
error_set (e, "unsupported");
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const char *name = NULL;
|
const char *name = NULL;
|
||||||
@@ -3252,10 +3251,25 @@ init_openrpc (struct app_context *ctx)
|
|||||||
str_map_set (&ctx->methods, name, (void *) 1);
|
str_map_set (&ctx->methods, name, (void *) 1);
|
||||||
}
|
}
|
||||||
json_decref (response);
|
json_decref (response);
|
||||||
if (e)
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
init_openrpc (struct app_context *ctx)
|
||||||
{
|
{
|
||||||
print_error ("OpenRPC: %s", e->message);
|
if (!ctx->openrpc)
|
||||||
error_free (e);
|
return;
|
||||||
|
|
||||||
|
json_t *id = json_integer (ctx->next_id++);
|
||||||
|
struct str buf = str_make ();
|
||||||
|
struct error *error;
|
||||||
|
if (!(error = json_rpc_call_raw (ctx, "rpc.discover", id, NULL, &buf)))
|
||||||
|
parse_rpc_discover (ctx, &buf, &error);
|
||||||
|
json_decref (id);
|
||||||
|
|
||||||
|
if (error)
|
||||||
|
{
|
||||||
|
print_error ("OpenRPC: %s", error->message);
|
||||||
|
error_free (error);
|
||||||
}
|
}
|
||||||
str_free (&buf);
|
str_free (&buf);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1014,7 +1014,7 @@ static int
|
|||||||
ws_handler_on_url (http_parser *parser, const char *at, size_t len)
|
ws_handler_on_url (http_parser *parser, const char *at, size_t len)
|
||||||
{
|
{
|
||||||
struct ws_handler *self = parser->data;
|
struct ws_handler *self = parser->data;
|
||||||
str_append_data (&self->value, at, len);
|
str_append_data (&self->url, at, len);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user