Skip to content

Commit 62166ba

Browse files
committed
libplugin: add macro to deprecate dynamic options
Changelog-None Signed-off-by: Lagrang3 <lagrang3@protonmail.com>
1 parent b7491a0 commit 62166ba

2 files changed

Lines changed: 21 additions & 8 deletions

File tree

plugins/libplugin.c

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2244,15 +2244,25 @@ static void ld_command_handle(struct plugin *plugin,
22442244
else
22452245
val = "true";
22462246

2247-
problem = popt->handle(cmd, val, check_only, popt->arg);
2248-
if (problem)
2247+
if (!deprecated_ok(plugin->deprecated_ok, popt->name,
2248+
popt->depr_start, popt->depr_end,
2249+
plugin->beglist, NULL, NULL)) {
22492250
ret = command_fail(cmd, JSONRPC2_INVALID_PARAMS,
2250-
"%s", problem);
2251-
else {
2252-
if (check_only)
2253-
ret = command_check_done(cmd);
2254-
else
2255-
ret = command_finished(cmd, jsonrpc_stream_success(cmd));
2251+
"Configuration %s is deprecated",
2252+
popt->name);
2253+
} else {
2254+
2255+
problem = popt->handle(cmd, val, check_only, popt->arg);
2256+
if (problem)
2257+
ret = command_fail(cmd, JSONRPC2_INVALID_PARAMS,
2258+
"%s", problem);
2259+
else {
2260+
if (check_only)
2261+
ret = command_check_done(cmd);
2262+
else
2263+
ret = command_finished(
2264+
cmd, jsonrpc_stream_success(cmd));
2265+
}
22562266
}
22572267
assert(ret == &complete);
22582268
return;

plugins/libplugin.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -629,6 +629,9 @@ void *plugin_get_data_(struct plugin *plugin);
629629
#define plugin_option_deprecated(name, type, description, depr_start, depr_end, set, jsonfmt, arg) \
630630
plugin_option_((name), (type), (description), (set), (jsonfmt), (arg), false, (depr_start), (depr_end), false, false)
631631

632+
#define plugin_option_deprecated_dynamic(name, type, description, depr_start, depr_end, set, jsonfmt, arg) \
633+
plugin_option_((name), (type), (description), (set), (jsonfmt), (arg), false, (depr_start), (depr_end), true, false)
634+
632635
#define plugin_option_multi(name, type, description, set, jsonfmt, arg) \
633636
plugin_option_((name), (type), (description), (set), (jsonfmt), (arg), false, NULL, NULL, false, true)
634637

0 commit comments

Comments
 (0)