diff options
author | gramanas <anastasis.gramm2@gmail.com> | 2018-11-19 01:54:32 +0200 |
---|---|---|
committer | gramanas <anastasis.gramm2@gmail.com> | 2018-11-19 01:54:32 +0200 |
commit | 84bbbb91c9154ca0b1c295eb7d1aa0de59450764 (patch) | |
tree | 781dc2760b6898e567058ce04779cb67a174ea72 /src | |
parent | a6290ec9d98e3b7cc650db134b17ee6d6a64f46d (diff) | |
download | ck-84bbbb91c9154ca0b1c295eb7d1aa0de59450764.tar.gz ck-84bbbb91c9154ca0b1c295eb7d1aa0de59450764.tar.bz2 ck-84bbbb91c9154ca0b1c295eb7d1aa0de59450764.zip |
Better error report on add
Diffstat (limited to 'src')
-rw-r--r-- | src/actions.h | 1 | ||||
-rw-r--r-- | src/add.c | 13 |
2 files changed, 11 insertions, 3 deletions
diff --git a/src/actions.h b/src/actions.h index 60b9645..1b7ef05 100644 --- a/src/actions.h +++ b/src/actions.h @@ -27,6 +27,7 @@ CK_ACTIONS enum AddOptErrors { ADD_NO_ERR = 0, ADD_ERR_WRONG_CONFIG, + ADD_ERR_LINK_CONFIG, ADD_ERR_WRONG_FLAGS }; typedef enum AddOptErrors AddOptErr; @@ -241,11 +241,15 @@ static AddOpt add_make_options(cklist *args) { }; list_next(args); - if (!util_is_file_rw(list_get(args)) - || !util_is_file_link(list_get(args))) { + strcpy(addOpt.confPath, list_get(args)); + if (!util_is_file_rw(addOpt.confPath)) { addOpt.err = ADD_ERR_WRONG_CONFIG; return addOpt; } + if (!util_is_file_link(addOpt.confPath)) { + addOpt.err = ADD_ERR_LINK_CONFIG; + return addOpt; + } realpath(list_get(args), addOpt.confPath); while (list_next(args)) { @@ -304,8 +308,11 @@ int run_ADD(UserOpt * opt, Conf *conf) { switch (addOpt.err) { case ADD_NO_ERR: break; + case ADD_ERR_LINK_CONFIG: + ERR("%s is a link.", addOpt.confPath); + goto error; case ADD_ERR_WRONG_CONFIG: - ERR("The config file specified doesn't exist or is a link."); + ERR("%s doesn't exist.", addOpt.confPath); goto error; case ADD_ERR_WRONG_FLAGS: ERR("Flags are: -s for secret and -p for primary."); |