feat(landerctl): properly find config file
ci/woodpecker/push/docker Pipeline was successful Details

release/0.2.0
Jef Roosens 2023-11-16 12:21:13 +01:00
parent 59da997828
commit e42004de94
Signed by: Jef Roosens
GPG Key ID: B75D4F293C7052DB
4 changed files with 18 additions and 5 deletions

View File

@ -16,7 +16,7 @@ LIB_DIRS = ./lsm/build
# 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
# prevents some errors when removing header files)
CFLAGS = -MMD -MP -g
CFLAGS ?= -MMD -MP -g
# When compiling release builds, these flags are better
# CLAGS = -O3

View File

@ -15,7 +15,7 @@ LIB_DIRS =
# 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
# prevents some errors when removing header files)
CFLAGS = -MMD -MP -g
CFLAGS ?= -MMD -MP -g
# When compiling release builds, these flags are better
# CLAGS = -O3

View File

@ -9,14 +9,27 @@
#include "landerctl.h"
const char *default_cfg_path = ".landerrc";
const char *cfg_file_name = ".landerrc";
const char *usage = "%s [-SPFsv] arg [key]\n";
int main(int argc, char **argv) {
landerctl_ctx ctx = {0};
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:
break;
case landerctl_cfg_err_not_found:

View File

@ -12,4 +12,4 @@ INC_DIRS = $(PUB_INC_DIR) src/_include
# 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
# prevents some errors when removing header files)
CFLAGS = -MMD -MP -g
CFLAGS ?= -MMD -MP -g