# HG changeset patch # User Olaf Wintermann # Date 1527418632 -7200 # Node ID d6d7c16dd066a33f47584206f6c7dfaeaec61d91 # Parent 222997d48ae143a2ba48ace1296f14ef2112cf47 adds list-tags command to dav-sync diff -r 222997d48ae1 -r d6d7c16dd066 dav/sync.c --- a/dav/sync.c Sun May 27 11:47:49 2018 +0200 +++ b/dav/sync.c Sun May 27 12:57:12 2018 +0200 @@ -134,6 +134,8 @@ ret = cmd_remove_tag(args); } else if(!strcmp(cmd, "update-tags")) { ret = cmd_update_tags(args); + } else if(!strcmp(cmd, "list-tags")) { + ret = cmd_list_tags(args); } else if(!strcmp(cmd, "add-dir") || !strcmp(cmd, "add-directory")) { ret = cmd_add_directory(args); @@ -174,7 +176,8 @@ fprintf(stderr, " empty-trash \n"); fprintf(stderr, " add-tag [-s ] \n"); fprintf(stderr, " remove-tag [-s ] \n"); - fprintf(stderr, " update-tags [-s ] [tags]\n\n"); + fprintf(stderr, " update-tags [-s ] [tags]\n"); + fprintf(stderr, " update-tags [-s ] \n\n"); fprintf(stderr, "Options:\n"); fprintf(stderr, " -c Disable conflict detection\n"); @@ -1443,7 +1446,7 @@ ret = -1; } } else { - // TODO: relete xattr + // TODO: delete xattr //ret = xattr_remove(path, dir->tagconfig->xattr_name); } } @@ -2073,6 +2076,7 @@ #define CMD_TAG_ADD 0 #define CMD_TAG_REMOVE 1 #define CMD_TAG_UPDATE 2 +#define CMD_TAG_LIST 3 int cmd_add_tag(CmdArgs *args) { if(args->argc != 2) { fprintf(stderr, "Too %s arguments\n", args->argc <= 1 ? "few" : "many"); @@ -2097,6 +2101,14 @@ return cmd_tagopt(args, CMD_TAG_UPDATE); } +int cmd_list_tags(CmdArgs *args) { + if(args->argc != 1) { + fprintf(stderr, "Too %s arguments\n", args->argc <= 1 ? "few" : "many"); + return -1; + } + return cmd_tagopt(args, CMD_TAG_LIST); +} + int cmd_tagopt(CmdArgs *args, int cmd) { SyncFile file; int ret = 0; @@ -2123,7 +2135,7 @@ UcxList *tags = NULL; DavBool store_tags = FALSE; - if(cmd == CMD_TAG_ADD || cmd == CMD_TAG_REMOVE) { + if(cmd != CMD_TAG_UPDATE) { char *tag = args->argv[1]; char *tagcolor = NULL; // TODO: get color @@ -2131,7 +2143,9 @@ UcxList *x = NULL; UCX_FOREACH(elm, tags) { DavTag *t = elm->data; - if(!strcmp(t->name, tag)) { + if(cmd == CMD_TAG_LIST) { + printf("%s\n", t->name); + } else if(!strcmp(t->name, tag)) { x = elm; break; } @@ -2145,7 +2159,7 @@ tags = ucx_list_append(tags, newtag); store_tags = TRUE; } - } else { + } else if(cmd == CMD_TAG_REMOVE) { if(tags) { tags = ucx_list_remove(tags, x); } diff -r 222997d48ae1 -r d6d7c16dd066 dav/sync.h --- a/dav/sync.h Sun May 27 11:47:49 2018 +0200 +++ b/dav/sync.h Sun May 27 12:57:12 2018 +0200 @@ -113,6 +113,7 @@ int cmd_add_tag(CmdArgs *args); int cmd_remove_tag(CmdArgs *args); int cmd_update_tags(CmdArgs *args); +int cmd_list_tags(CmdArgs *args); int cmd_tagopt(CmdArgs *args, int cmd); /* diff -r 222997d48ae1 -r d6d7c16dd066 dav/version.h --- a/dav/version.h Sun May 27 11:47:49 2018 +0200 +++ b/dav/version.h Sun May 27 12:57:12 2018 +0200 @@ -27,6 +27,6 @@ */ #ifndef DAV_VERSION -#define DAV_VERSION "1.1 dev" +#define DAV_VERSION "1.2 RC1" #endif