diff -r cd30c7a7baf8 -r 1950f483d3c4 dav/main.c --- a/dav/main.c Sat Feb 27 17:23:36 2016 +0100 +++ b/dav/main.c Sat Feb 27 19:39:55 2016 +0100 @@ -43,6 +43,7 @@ #include #include "config.h" #include "error.h" +#include "assistant.h" #include "main.h" static DavContext *ctx; @@ -120,6 +121,8 @@ ret = cmd_get_property(args); } else if(!strcasecmp(cmd, "info")) { ret = cmd_info(args); + } else if(!strcasecmp(cmd, "create-repository")) { + ret = cmd_create_repository(args); } else if(!strcasecmp(cmd, "version") || !strcasecmp(cmd, "-version") || !strcasecmp(cmd, "--version")) { #ifdef DEBUG fprintf(stderr, "dav %s unstable\n", DAV_VERSION); @@ -180,6 +183,9 @@ fprintf(stderr, " -n specify namespace uri\n"); fprintf(stderr, " -v verbose output\n"); fprintf(stderr, "\n"); + fprintf(stderr, "Config Commands:\n"); + fprintf(stderr, " add-repository\n"); + fprintf(stderr, "\n"); fprintf(stderr, "Instead of an url you can pass a repository name " "with an optional path:\n"); @@ -1150,73 +1156,53 @@ } } + /* ---------- config commands ---------- */ -static int getkeyvalue(char *arg, char **key, char **value) { - // splits a key=value arg +int cmd_create_repository(CmdArgs *args) { + sstr_t line; - *key = NULL; - *value = NULL; - if(!arg && !key && !value) { + printf("Each repository must have an unique name.\n"); + char *name = assistant_getcfg("name"); + if(!name) { + fprintf(stderr, "Abort\n"); + return -1; + } + if(get_repository(sstr(name))) { + fprintf(stderr, "Repository %s already exists.\nAbort\n"); return -1; } - int haskey = 0; - size_t len = strlen(arg); - - if(len < 3) { + printf("\nSpecify the repository base url.\n"); + char *url = assistant_getcfg("url"); + if(!url) { + fprintf(stderr, "Abort\n"); return -1; } - int i; - for(i=0;i