Skip to content

Commit

Permalink
feat: restructure plugin and options in listconfigs
Browse files Browse the repository at this point in the history
This will change the command `listconfigs` output in two ways:

 - remove duplicated "plugin" JSON output by replacing it with
 - a "plugins" substructure which maps plugin cmd/name to their options

Changelog-Changed: JSON-RPC: `listconfigs` now structures plugins and include their options
  • Loading branch information
m-schmoock committed Nov 21, 2019
1 parent 654faa6 commit 3237119
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion lightningd/plugin.c
Original file line number Diff line number Diff line change
Expand Up @@ -1086,9 +1086,24 @@ void json_add_opt_plugins(struct json_stream *response,
const struct plugins *plugins)
{
struct plugin *p;
struct plugin_opt *opt;
const char *name;

// we output 'plugins' and their config as substructure:
// "plugins" : { "name" -> { "param" : "value" }, ... }
json_object_start(response, "plugins");
list_for_each(&plugins->plugins, p, list) {
json_add_string(response, "plugin", p->cmd);
json_object_start(response, p->cmd);
list_for_each(&p->plugin_opts, opt, list) {
/* Trim the `--` that we added before */
name = opt->name + 2;
if (opt->value->as_str) {
json_add_string(response, name, opt->value->as_str);
}
}
json_object_end(response);
}
json_object_end(response);
}

/**
Expand Down

0 comments on commit 3237119

Please sign in to comment.