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