added list-repositories and list-directories commands

Sat, 27 Feb 2016 21:04:37 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Sat, 27 Feb 2016 21:04:37 +0100
changeset 198
44054c452de1
parent 197
79a866256be4
child 199
f448fc8c9191

added list-repositories and list-directories commands

dav/config.c file | annotate | diff | comparison | revisions
dav/config.h file | annotate | diff | comparison | revisions
dav/main.c file | annotate | diff | comparison | revisions
dav/scfg.c file | annotate | diff | comparison | revisions
dav/scfg.h file | annotate | diff | comparison | revisions
dav/sync.c file | annotate | diff | comparison | revisions
--- a/dav/config.c	Sat Feb 27 19:53:43 2016 +0100
+++ b/dav/config.c	Sat Feb 27 21:04:37 2016 +0100
@@ -524,3 +524,12 @@
     
     return ret;
 }
+
+int list_repositories() {
+    UcxMapIterator i = ucx_map_iterator(repos);
+    Repository *repo;
+    UCX_MAP_FOREACH(key, repo, i) {
+        printf("%s\n", repo->name);
+    }
+    return 0;
+}
--- a/dav/config.h	Sat Feb 27 19:53:43 2016 +0100
+++ b/dav/config.h	Sat Feb 27 21:04:37 2016 +0100
@@ -91,6 +91,7 @@
 Proxy* get_https_proxy();
 
 int add_repository(Repository *repo);
+int list_repositories();
 
 #ifdef	__cplusplus
 }
--- a/dav/main.c	Sat Feb 27 19:53:43 2016 +0100
+++ b/dav/main.c	Sat Feb 27 21:04:37 2016 +0100
@@ -123,6 +123,8 @@
         ret = cmd_info(args);
     } else if(!strcasecmp(cmd, "add-repository")) {
         ret = cmd_add_repository(args);
+    } else if(!strcasecmp(cmd, "list-repositories")) {
+        ret = list_repositories();
     } else if(!strcasecmp(cmd, "version") || !strcasecmp(cmd, "-version") || !strcasecmp(cmd, "--version")) {
 #ifdef DEBUG
         fprintf(stderr, "dav %s unstable\n", DAV_VERSION);
@@ -183,8 +185,9 @@
     fprintf(stderr, "        -n <uri>   specify namespace uri\n");
     fprintf(stderr, "        -v         verbose output\n");
     fprintf(stderr, "\n");
-    fprintf(stderr, "Config Commands:\n");
+    fprintf(stderr, "Config commands:\n");
     fprintf(stderr, "        add-repository\n");
+    fprintf(stderr, "        list-repositories\n");
     fprintf(stderr, "\n");
     fprintf(stderr,
             "Instead of an url you can pass a repository name "
@@ -766,11 +769,7 @@
                 return -1;
             }
         } else {
-            if(sn->errorstr) {
-                fprintf(stderr, "Error: %s\n", sn->errorstr);
-            } else {
-                fprintf(stderr, "Error\n");
-            }
+            print_resource_error(sn, path);
             return -1;
         }
     } else if(res->iscollection) {
--- a/dav/scfg.c	Sat Feb 27 19:53:43 2016 +0100
+++ b/dav/scfg.c	Sat Feb 27 21:04:37 2016 +0100
@@ -225,3 +225,12 @@
 SyncDirectory* scfg_get_dir(char *name) {
     return ucx_map_cstr_get(directories, name);
 }
+
+int list_syncdirs() {
+    UcxMapIterator i = ucx_map_iterator(directories);
+    SyncDirectory *dir;
+    UCX_MAP_FOREACH(key, dir, i) {
+        printf("%s\n", dir->name);
+    }
+    return 0;
+}
--- a/dav/scfg.h	Sat Feb 27 19:53:43 2016 +0100
+++ b/dav/scfg.h	Sat Feb 27 21:04:37 2016 +0100
@@ -61,6 +61,8 @@
 
 SyncDirectory* scfg_get_dir(char *name);
 
+int list_syncdirs();
+
 
 #ifdef	__cplusplus
 }
--- a/dav/sync.c	Sat Feb 27 19:53:43 2016 +0100
+++ b/dav/sync.c	Sat Feb 27 21:04:37 2016 +0100
@@ -89,6 +89,8 @@
         ret = cmd_pull(args);
     } else if(!strcmp(cmd, "push")) {
         ret = cmd_push(args);
+    } else if(!strcmp(cmd, "list-directories")) {
+        ret = list_syncdirs();
     } else if(!strcasecmp(cmd, "version") || !strcasecmp(cmd, "-version") || !strcasecmp(cmd, "--version")) {
 #ifdef DEBUG
         fprintf(stderr, "dav-sync %s unstable\n", DAV_VERSION);
@@ -113,6 +115,9 @@
     fprintf(stderr, "Options:\n");
     fprintf(stderr, "        -c         Disable conflict detection\n\n");
     //fprintf(stderr, "        -r         Read changes from stdin\n\n");
+    
+    fprintf(stderr, "Config commands:\n");
+    fprintf(stderr, "        list-directories\n\n");
 }
 
 static int res_matches_filter(SyncDirectory *dir, char *res_path) {

mercurial