feat(landerctl): properly find config file
ci/woodpecker/push/docker Pipeline was successful
Details
ci/woodpecker/push/docker Pipeline was successful
Details
parent
59da997828
commit
e42004de94
|
@ -16,7 +16,7 @@ LIB_DIRS = ./lsm/build
|
||||||
# object file is also recompiled if only a header is changed.
|
# object file is also recompiled if only a header is changed.
|
||||||
# -MP: generate a dummy target for every header file (according to the docs it
|
# -MP: generate a dummy target for every header file (according to the docs it
|
||||||
# prevents some errors when removing header files)
|
# prevents some errors when removing header files)
|
||||||
CFLAGS = -MMD -MP -g
|
CFLAGS ?= -MMD -MP -g
|
||||||
|
|
||||||
# When compiling release builds, these flags are better
|
# When compiling release builds, these flags are better
|
||||||
# CLAGS = -O3
|
# CLAGS = -O3
|
||||||
|
|
|
@ -15,7 +15,7 @@ LIB_DIRS =
|
||||||
# object file is also recompiled if only a header is changed.
|
# object file is also recompiled if only a header is changed.
|
||||||
# -MP: generate a dummy target for every header file (according to the docs it
|
# -MP: generate a dummy target for every header file (according to the docs it
|
||||||
# prevents some errors when removing header files)
|
# prevents some errors when removing header files)
|
||||||
CFLAGS = -MMD -MP -g
|
CFLAGS ?= -MMD -MP -g
|
||||||
|
|
||||||
# When compiling release builds, these flags are better
|
# When compiling release builds, these flags are better
|
||||||
# CLAGS = -O3
|
# CLAGS = -O3
|
||||||
|
|
|
@ -9,14 +9,27 @@
|
||||||
|
|
||||||
#include "landerctl.h"
|
#include "landerctl.h"
|
||||||
|
|
||||||
const char *default_cfg_path = ".landerrc";
|
const char *cfg_file_name = ".landerrc";
|
||||||
const char *usage = "%s [-SPFsv] arg [key]\n";
|
const char *usage = "%s [-SPFsv] arg [key]\n";
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
landerctl_ctx ctx = {0};
|
landerctl_ctx ctx = {0};
|
||||||
char *err_msg = NULL;
|
char *err_msg = NULL;
|
||||||
|
|
||||||
switch (landerctl_cfg_parse(&ctx.cfg, default_cfg_path)) {
|
landerctl_cfg_err parse_res;
|
||||||
|
|
||||||
|
const char *home_dir = getenv("HOME");
|
||||||
|
|
||||||
|
if (home_dir == NULL) {
|
||||||
|
parse_res = landerctl_cfg_parse(&ctx.cfg, cfg_file_name);
|
||||||
|
} else {
|
||||||
|
char cfg_path[strlen(home_dir) + strlen(cfg_file_name) + 2];
|
||||||
|
sprintf(cfg_path, "%s/%s", home_dir, cfg_file_name);
|
||||||
|
|
||||||
|
parse_res = landerctl_cfg_parse(&ctx.cfg, cfg_path);
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (parse_res) {
|
||||||
case landerctl_cfg_err_ok:
|
case landerctl_cfg_err_ok:
|
||||||
break;
|
break;
|
||||||
case landerctl_cfg_err_not_found:
|
case landerctl_cfg_err_not_found:
|
||||||
|
|
|
@ -12,4 +12,4 @@ INC_DIRS = $(PUB_INC_DIR) src/_include
|
||||||
# object file is also recompiled if only a header is changed.
|
# object file is also recompiled if only a header is changed.
|
||||||
# -MP: generate a dummy target for every header file (according to the docs it
|
# -MP: generate a dummy target for every header file (according to the docs it
|
||||||
# prevents some errors when removing header files)
|
# prevents some errors when removing header files)
|
||||||
CFLAGS = -MMD -MP -g
|
CFLAGS ?= -MMD -MP -g
|
||||||
|
|
Loading…
Reference in New Issue