Fri, 30 Aug 2013 12:48:15 +0200
errors on too many arguments
dav/main.c | file | annotate | diff | comparison | revisions |
--- a/dav/main.c Mon Aug 26 14:44:21 2013 +0200 +++ b/dav/main.c Fri Aug 30 12:48:15 2013 +0200 @@ -196,8 +196,8 @@ int cmd_list(CmdArgs *a) { - if(a->argc == 0) { - fprintf(stderr, "Too few arguments\n"); + if(a->argc != 1) { + fprintf(stderr, "Too %s arguments\n", a->argc < 1 ? "few":"many"); return -1; } @@ -427,8 +427,9 @@ } int cmd_get(CmdArgs *a) { - if(a->argc == 0) { - fprintf(stderr, "Too few arguments\n"); + if(a->argc != 1) { + // TODO: change this, when get supports retrieval of multiple files + fprintf(stderr, "Too %s arguments\n", a->argc < 1 ? "few":"many"); return -1; } @@ -618,8 +619,9 @@ } int cmd_put(CmdArgs *a) { - if(a->argc < 2) { - fprintf(stderr, "Too few arguments\n"); + if(a->argc != 2) { + // TODO: change, when put supports multiple files (however it should do) + fprintf(stderr, "Too %s arguments\n", a->argc < 2 ? "few":"many"); return -1; } @@ -771,8 +773,9 @@ int cmd_remove(CmdArgs *a) { - if(a->argc < 1) { - fprintf(stderr, "Too few arguments\n"); + if(a->argc != 1) { + // TODO: change, when removal of multiple files is supported + fprintf(stderr, "Too %s arguments\n", a->argc < 1 ? "few":"many"); return -1; } @@ -805,8 +808,9 @@ } int cmd_mkdir(CmdArgs *a) { - if(a->argc < 1) { - fprintf(stderr, "Too few arguments\n"); + if(a->argc != 1) { + // TODO: change, when creation of multiple dirs is supported + fprintf(stderr, "Too %s arguments\n", a->argc < 1 ? "few":"many"); return -1; } @@ -861,7 +865,7 @@ putenv("LC_TIME=C"); size_t len = strftime(str, 32, "%a, %d %b %Y %H:%M:%S GMT\n", date); fwrite(str, 1, len, stdout); - } else { + } else if (a->argc == 1) { DavSession *sn = NULL; char *url = a->argv[0]; char *root = NULL; @@ -884,8 +888,11 @@ } else { return -1; } + return 0; + } else { + fprintf(stderr, "Too many arguments\n"); + return -1; } - return 0; } int cmd_sync(CmdArgs *a) {