| 259 | } |
| 260 | |
| 261 | static struct command_result *json_listconfigs(struct command *cmd, |
| 262 | const char *buffer, |
| 263 | const jsmntok_t *obj UNNEEDED, |
| 264 | const jsmntok_t *params) |
| 265 | { |
| 266 | struct json_stream *response = NULL; |
| 267 | const struct opt_table *config; |
| 268 | |
| 269 | if (!param(cmd, buffer, params, |
| 270 | p_opt("config", param_opt_config, &config), |
| 271 | NULL)) |
| 272 | return command_param_failed(); |
| 273 | |
| 274 | response = json_stream_success(cmd); |
| 275 | json_object_start(response, "configs"); |
| 276 | for (size_t i = 0; i < opt_count; i++) { |
| 277 | const char **names; |
| 278 | |
| 279 | /* FIXME: Print out comment somehow? */ |
| 280 | if (opt_table[i].type == OPT_SUBTABLE) |
| 281 | continue; |
| 282 | |
| 283 | if (config && config != &opt_table[i]) |
| 284 | continue; |
| 285 | |
| 286 | names = opt_names_arr(tmpctx, &opt_table[i]); |
| 287 | /* We don't usually print dev or deprecated options, unless |
| 288 | * they explicitly ask, or they're set. */ |
| 289 | json_add_config(cmd->ld, response, config != NULL, true, |
| 290 | &opt_table[i], names); |
| 291 | } |
| 292 | json_object_end(response); |
| 293 | |
| 294 | return command_success(cmd, response); |
| 295 | } |
| 296 | |
| 297 | static const struct json_command listconfigs_command = { |
| 298 | "listconfigs", |
nothing calls this directly
no test coverage detected