mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 23:24:27 +01:00
daemon/options: split option registration and parsing.
This allows us to add extra options before parsing. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
@@ -71,6 +71,7 @@ int main(int argc, char *argv[])
|
|||||||
| SECP256K1_CONTEXT_SIGN);
|
| SECP256K1_CONTEXT_SIGN);
|
||||||
|
|
||||||
/* Handle options and config; move to .lightningd */
|
/* Handle options and config; move to .lightningd */
|
||||||
|
register_opts(dstate);
|
||||||
handle_opts(dstate, argc, argv);
|
handle_opts(dstate, argc, argv);
|
||||||
|
|
||||||
/* Activate crash log now we're in the right place. */
|
/* Activate crash log now we're in the right place. */
|
||||||
|
|||||||
@@ -447,10 +447,8 @@ static void opt_parse_from_config(struct lightningd_state *dstate)
|
|||||||
tal_free(contents);
|
tal_free(contents);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool handle_opts(struct lightningd_state *dstate, int argc, char *argv[])
|
void register_opts(struct lightningd_state *dstate)
|
||||||
{
|
{
|
||||||
bool newdir = false;
|
|
||||||
|
|
||||||
opt_set_alloc(opt_allocfn, tal_reallocfn, tal_freefn);
|
opt_set_alloc(opt_allocfn, tal_reallocfn, tal_freefn);
|
||||||
|
|
||||||
opt_register_early_noarg("--help|-h", opt_usage_and_exit,
|
opt_register_early_noarg("--help|-h", opt_usage_and_exit,
|
||||||
@@ -469,6 +467,11 @@ bool handle_opts(struct lightningd_state *dstate, int argc, char *argv[])
|
|||||||
&dstate->config_dir, &dstate->rpc_filename);
|
&dstate->config_dir, &dstate->rpc_filename);
|
||||||
config_register_opts(dstate);
|
config_register_opts(dstate);
|
||||||
dev_register_opts(dstate);
|
dev_register_opts(dstate);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool handle_opts(struct lightningd_state *dstate, int argc, char *argv[])
|
||||||
|
{
|
||||||
|
bool newdir = false;
|
||||||
|
|
||||||
/* Get any configdir/testnet options first. */
|
/* Get any configdir/testnet options first. */
|
||||||
opt_early_parse(argc, argv, opt_log_stderr_exit);
|
opt_early_parse(argc, argv, opt_log_stderr_exit);
|
||||||
|
|||||||
@@ -5,6 +5,9 @@
|
|||||||
|
|
||||||
struct lightningd_state;
|
struct lightningd_state;
|
||||||
|
|
||||||
|
/* You can register additional options *after* this if you want. */
|
||||||
|
void register_opts(struct lightningd_state *dstate);
|
||||||
|
|
||||||
/* After this, we're in the .lightning dir, config file parsed.
|
/* After this, we're in the .lightning dir, config file parsed.
|
||||||
* If we just created the dir, returns true.
|
* If we just created the dir, returns true.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -176,6 +176,7 @@ int main(int argc, char *argv[])
|
|||||||
ld->daemon_dir = find_my_path(ld, argv[0]);
|
ld->daemon_dir = find_my_path(ld, argv[0]);
|
||||||
|
|
||||||
/* Handle options and config; move to .lightningd */
|
/* Handle options and config; move to .lightningd */
|
||||||
|
register_opts(&ld->dstate);
|
||||||
newdir = handle_opts(&ld->dstate, argc, argv);
|
newdir = handle_opts(&ld->dstate, argc, argv);
|
||||||
|
|
||||||
/* Activate crash log now we're in the right place. */
|
/* Activate crash log now we're in the right place. */
|
||||||
|
|||||||
Reference in New Issue
Block a user