aboutsummaryrefslogtreecommitdiffstats
path: root/src/actions.c
diff options
context:
space:
mode:
authorgramanas <anastasis.gramm2@gmail.com>2018-10-09 20:53:30 +0300
committergramanas <anastasis.gramm2@gmail.com>2018-10-09 20:53:30 +0300
commit598e0522de924a50ea9c640955daab8512029eb4 (patch)
tree3f3cf027349a414e2f24d1a4c7976916e8b7dc21 /src/actions.c
parentfe781e5ae7116733e5b335a0ac016af97266db5f (diff)
downloadck-598e0522de924a50ea9c640955daab8512029eb4.tar.gz
ck-598e0522de924a50ea9c640955daab8512029eb4.tar.bz2
ck-598e0522de924a50ea9c640955daab8512029eb4.zip
Better list
Diffstat (limited to 'src/actions.c')
-rw-r--r--src/actions.c37
1 files changed, 32 insertions, 5 deletions
diff --git a/src/actions.c b/src/actions.c
index 4ff6816..1b4c9b5 100644
--- a/src/actions.c
+++ b/src/actions.c
@@ -134,8 +134,11 @@ int run_EDIT(UserOpt *opt, Conf *conf) {
/* If the program has many configs */
else {
HELP("Ambiguous config. Please type the config name after the program.");
- cklist *paths = list_make_new();
- edit_get_avaliable_paths(&db, paths, pName);
+ char name[STR_M] = "";
+ strcat(name, pName);
+ strcat(name, ":");
+ cklist *paths = list_make_and_add(name);
+ get_program_paths(&db, paths, pName, 1, 0);
list_print(paths);
list_free(paths);
goto error;
@@ -147,8 +150,11 @@ int run_EDIT(UserOpt *opt, Conf *conf) {
char *cName = list_get(opt->args);
if (edit_get_config(&db, pName, confName, cName, &secret)) {
ERR("Program %s doesn't have a config named %s", pName, cName);
- cklist *paths = list_make_new();
- edit_get_avaliable_paths(&db, paths, pName);
+ char name[STR_M] = "";
+ strcat(name, pName);
+ strcat(name, ":");
+ cklist *paths = list_make_and_add(name);
+ get_program_paths(&db, paths, pName, 1, 0);
list_print(paths);
list_free(paths);
goto error;
@@ -171,7 +177,6 @@ int run_EDIT(UserOpt *opt, Conf *conf) {
}
int run_LIST(UserOpt *opt, Conf *conf) {
- UNUSED(conf);
DB db = open_DB(opt);
if (db.ptr == NULL) {
if (db.error == SQL_ERR_NO_TABLES) {
@@ -186,6 +191,7 @@ int run_LIST(UserOpt *opt, Conf *conf) {
if (listOpt.err) {
goto error;
}
+ char tmp[STR_L] = "";
switch(listOpt._lt) {
case LT_PATH:
list_get_paths(&db, the_list, listOpt.attr);
@@ -197,6 +203,27 @@ int run_LIST(UserOpt *opt, Conf *conf) {
list_get_path_program_tree(&db, the_list, listOpt.attr);
list_print(the_list);
goto close;
+ case LT_CKCONF:
+ strcat(tmp, "ck configuration directory path: ");
+ strcat(tmp, opt->confDir);
+ list_add(the_list, tmp);
+#define X(var, str, name) \
+ strcpy(tmp, ""); \
+ strcat(tmp, name); \
+ strcat(tmp, ": "); \
+ strcat(tmp, conf->var); \
+ list_add(the_list, tmp);
+ CONFIG_VARIABLES_TABLE;
+#undef X
+ list_print(the_list);
+ goto close;
+ case LT_PROG_CONFS:
+ if (!program_exists(&db, listOpt.pName)) {
+ ERR("Program %s doesn't exist in the database.", listOpt.pName);
+ goto error;
+ }
+ get_program_paths(&db, the_list, listOpt.pName, 0, listOpt.attr);
+ break;
case LT_NONE:
goto error;
}