core-lightning/common/configdir.c
Rusty Russell 8375857116 common: absorb remaining files from daemon/
Also, we split the more sophisticated json_add helpers to avoid pulling in
everything into lightning-cli, and unify the routines to print struct
short_channel_id (it's ':',  not '/' too).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-08-29 17:54:14 +02:00

32 lines
776 B
C

#include "configdir.h"
#include <ccan/opt/opt.h>
#include <ccan/tal/path/path.h>
#include <ccan/tal/str/str.h>
#include <errno.h>
static char *default_configdir(const tal_t *ctx)
{
char *path;
const char *env = getenv("HOME");
if (!env)
return ".";
path = path_join(ctx, env, ".lightning");
return path;
}
void configdir_register_opts(const tal_t *ctx,
char **configdir, char **rpc_filename)
{
*configdir = default_configdir(ctx);
*rpc_filename = "lightning-rpc";
opt_register_early_arg("--lightning-dir", opt_set_charp, opt_show_charp,
configdir,
"working directory: all other files are relative to this");
opt_register_arg("--rpc-file", opt_set_charp, opt_show_charp,
rpc_filename,
"Set JSON-RPC socket (or /dev/tty)");
}