bug fixing
This commit is contained in:
parent
9905e9fada
commit
cbbbf68db0
2 changed files with 20 additions and 19 deletions
|
@ -86,12 +86,14 @@ int main(int argc, char **argv) {
|
||||||
size_t lists_len = 0;
|
size_t lists_len = 0;
|
||||||
klist_list **lists = NULL;
|
klist_list **lists = NULL;
|
||||||
if (list_ctx->name) {
|
if (list_ctx->name) {
|
||||||
klist_list *list = klist_list_get_by_user_and_name(ctx, user->id, list_ctx->name);
|
klist_list *list =
|
||||||
|
klist_list_get_by_user_and_name(ctx, user->id, list_ctx->name);
|
||||||
if (list) {
|
if (list) {
|
||||||
lists_len = 1;
|
lists_len = 1;
|
||||||
lists = &list;
|
lists = &list;
|
||||||
};
|
};
|
||||||
} else lists = klist_list_get_all_by_user(ctx, user->id, &lists_len);
|
} else
|
||||||
|
lists = klist_list_get_all_by_user(ctx, user->id, &lists_len);
|
||||||
if (lists) {
|
if (lists) {
|
||||||
i = 0;
|
i = 0;
|
||||||
for (; i < lists_len; i++) {
|
for (; i < lists_len; i++) {
|
||||||
|
@ -106,11 +108,10 @@ int main(int argc, char **argv) {
|
||||||
klist_task_deinit(tasks[i]);
|
klist_task_deinit(tasks[i]);
|
||||||
free(tasks);
|
free(tasks);
|
||||||
}
|
}
|
||||||
} else
|
} else if (list_ctx->name)
|
||||||
if (list_ctx->name)
|
fprintf(stderr, "List '%s' not found.\n", list_ctx->name);
|
||||||
fprintf(stderr, "List '%s' not found.\n", list_ctx->name);
|
else
|
||||||
else
|
fprintf(stderr, "No lists found.\n");
|
||||||
fprintf(stderr, "No lists found.\n");
|
|
||||||
break;
|
break;
|
||||||
case LIST_DELETE:
|
case LIST_DELETE:
|
||||||
list = klist_list_get_by_user_and_name(ctx, user->id, list_ctx->name);
|
list = klist_list_get_by_user_and_name(ctx, user->id, list_ctx->name);
|
||||||
|
@ -294,7 +295,6 @@ void setup(klist *ctx, int argc, char **argv) {
|
||||||
ctx->cmd_ctx = list_ctx;
|
ctx->cmd_ctx = list_ctx;
|
||||||
if (argc < 3) {
|
if (argc < 3) {
|
||||||
list_ctx->cmd = LIST_GET;
|
list_ctx->cmd = LIST_GET;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -320,16 +320,16 @@ void setup(klist *ctx, int argc, char **argv) {
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
print_help(argv);
|
print_help(argv);
|
||||||
fprintf(
|
fprintf(stderr,
|
||||||
stderr,
|
""
|
||||||
""
|
"list options:\n"
|
||||||
"list options:\n"
|
"-a\t\tadd a list\n"
|
||||||
"-a\t\tadd a list\n"
|
"-e\t\tedit a list\n"
|
||||||
"-e\t\tedit a list\n"
|
"-d\t\tdelete a list\n"
|
||||||
"-d\t\tdelete a list\n"
|
"-p <preset>\tdefine as preset or use existing one with name "
|
||||||
"-p <preset>\tdefine as preset or use existing one with name "
|
"<preset>\n"
|
||||||
"<preset>\n"
|
"Not providing a parameter prints all lists and existing "
|
||||||
"Not providing a parameter prints all lists and existing presets.\n\n");
|
"presets.\n\n");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case TASK:
|
case TASK:
|
||||||
|
|
|
@ -56,7 +56,8 @@ const char *klist_sql_get(const enum KLIST_SQL sql) {
|
||||||
return "select users.*, user_logins.local_id from users inner join "
|
return "select users.*, user_logins.local_id from users inner join "
|
||||||
"user_logins on user_logins.user_id = users.id where users.id = ?1";
|
"user_logins on user_logins.user_id = users.id where users.id = ?1";
|
||||||
case GET_USER_BY_LOCAL:
|
case GET_USER_BY_LOCAL:
|
||||||
return "select * from users inner join user_logins on user_logins.user_id = users.id where user_logins.local_id = ?1";
|
return "select * from users inner join user_logins on user_logins.user_id "
|
||||||
|
"= users.id where user_logins.local_id = ?1";
|
||||||
case GET_USERS:
|
case GET_USERS:
|
||||||
return "select * from users";
|
return "select * from users";
|
||||||
case MOD_USER_NAME:
|
case MOD_USER_NAME:
|
||||||
|
|
Loading…
Add table
Reference in a new issue