dav/optparser.c

Sat, 28 Mar 2020 16:28:52 +0100

author
Mike Becker <universe@uap-core.de>
date
Sat, 28 Mar 2020 16:28:52 +0100
branch
feature/dav-edit
changeset 712
c62af832a0e2
parent 684
a4b4257c1a5f
child 721
c401f4af44b1
permissions
-rw-r--r--

adds documentation of crypto flags to edit command

11
5db6178d8b58 added usage info
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1 /*
5db6178d8b58 added usage info
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
5db6178d8b58 added usage info
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
3 *
364
3769ba002fd1 updates copyright date
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 355
diff changeset
4 * Copyright 2018 Olaf Wintermann. All rights reserved.
11
5db6178d8b58 added usage info
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
5 *
5db6178d8b58 added usage info
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
6 * Redistribution and use in source and binary forms, with or without
5db6178d8b58 added usage info
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
7 * modification, are permitted provided that the following conditions are met:
5db6178d8b58 added usage info
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
8 *
5db6178d8b58 added usage info
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
9 * 1. Redistributions of source code must retain the above copyright
5db6178d8b58 added usage info
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
10 * notice, this list of conditions and the following disclaimer.
5db6178d8b58 added usage info
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
11 *
5db6178d8b58 added usage info
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
12 * 2. Redistributions in binary form must reproduce the above copyright
5db6178d8b58 added usage info
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
13 * notice, this list of conditions and the following disclaimer in the
5db6178d8b58 added usage info
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
14 * documentation and/or other materials provided with the distribution.
5db6178d8b58 added usage info
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
15 *
5db6178d8b58 added usage info
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
5db6178d8b58 added usage info
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
5db6178d8b58 added usage info
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
5db6178d8b58 added usage info
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
5db6178d8b58 added usage info
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
5db6178d8b58 added usage info
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
5db6178d8b58 added usage info
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
5db6178d8b58 added usage info
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
5db6178d8b58 added usage info
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
5db6178d8b58 added usage info
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
5db6178d8b58 added usage info
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
26 * POSSIBILITY OF SUCH DAMAGE.
5db6178d8b58 added usage info
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
27 */
5db6178d8b58 added usage info
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
28
5db6178d8b58 added usage info
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
29 #include <stdio.h>
5db6178d8b58 added usage info
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
30 #include <stdlib.h>
5db6178d8b58 added usage info
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
31 #include <string.h>
5db6178d8b58 added usage info
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
32
5db6178d8b58 added usage info
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
33 #include "optparser.h"
375
39fd327f81da fixes options parser to correctly report missing arguments
Mike Becker <universe@uap-core.de>
parents: 364
diff changeset
34 #include "sopt.h"
11
5db6178d8b58 added usage info
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
35
5db6178d8b58 added usage info
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
36 void cmd_args_free(CmdArgs *args) {
219
9792cfe63b80 added resolve-conflicts and delete-conflicts to help text and fixed crash with unknown cmd options
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 213
diff changeset
37 if(args) {
9792cfe63b80 added resolve-conflicts and delete-conflicts to help text and fixed crash with unknown cmd options
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 213
diff changeset
38 ucx_map_free(args->options);
684
a4b4257c1a5f improve shell completion
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 517
diff changeset
39 if(args->argv) {
a4b4257c1a5f improve shell completion
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 517
diff changeset
40 free(args->argv);
a4b4257c1a5f improve shell completion
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 517
diff changeset
41 }
219
9792cfe63b80 added resolve-conflicts and delete-conflicts to help text and fixed crash with unknown cmd options
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 213
diff changeset
42 free(args);
9792cfe63b80 added resolve-conflicts and delete-conflicts to help text and fixed crash with unknown cmd options
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 213
diff changeset
43 }
11
5db6178d8b58 added usage info
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
44 }
5db6178d8b58 added usage info
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
45
5db6178d8b58 added usage info
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
46 CmdArgs* cmd_parse_args(int argc, char **argv) {
5db6178d8b58 added usage info
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
47 CmdArgs *a = malloc(sizeof(CmdArgs));
5db6178d8b58 added usage info
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
48 a->options = ucx_map_new(16);
684
a4b4257c1a5f improve shell completion
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 517
diff changeset
49 a->argv = argc > 0 ? calloc(argc, sizeof(char*)) : NULL;
11
5db6178d8b58 added usage info
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
50 a->argc = 0;
5db6178d8b58 added usage info
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
51
68
f6d3db6113d3 added verbose option + encryption flag fixes
Mike Becker <universe@uap-core.de>
parents: 62
diff changeset
52 const char *NOARG = "";
f6d3db6113d3 added verbose option + encryption flag fixes
Mike Becker <universe@uap-core.de>
parents: 62
diff changeset
53
11
5db6178d8b58 added usage info
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
54 char *option = NULL;
5db6178d8b58 added usage info
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
55 char optchar = 0;
5db6178d8b58 added usage info
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
56 for(int i=0;i<argc;i++) {
5db6178d8b58 added usage info
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
57 char *arg = argv[i];
5db6178d8b58 added usage info
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
58 size_t len = strlen(arg);
5db6178d8b58 added usage info
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
59 if(len > 1 && arg[0] == '-') {
5db6178d8b58 added usage info
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
60 for(int c=1;c<len;c++) {
375
39fd327f81da fixes options parser to correctly report missing arguments
Mike Becker <universe@uap-core.de>
parents: 364
diff changeset
61 if (option) {
39fd327f81da fixes options parser to correctly report missing arguments
Mike Becker <universe@uap-core.de>
parents: 364
diff changeset
62 fprintf(stderr,
39fd327f81da fixes options parser to correctly report missing arguments
Mike Becker <universe@uap-core.de>
parents: 364
diff changeset
63 "Missing argument for option -%c\n\n", optchar);
39fd327f81da fixes options parser to correctly report missing arguments
Mike Becker <universe@uap-core.de>
parents: 364
diff changeset
64 cmd_args_free(a);
39fd327f81da fixes options parser to correctly report missing arguments
Mike Becker <universe@uap-core.de>
parents: 364
diff changeset
65 return NULL;
39fd327f81da fixes options parser to correctly report missing arguments
Mike Becker <universe@uap-core.de>
parents: 364
diff changeset
66 }
39fd327f81da fixes options parser to correctly report missing arguments
Mike Becker <universe@uap-core.de>
parents: 364
diff changeset
67
11
5db6178d8b58 added usage info
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
68 switch(arg[c]) {
5db6178d8b58 added usage info
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
69 default: {
219
9792cfe63b80 added resolve-conflicts and delete-conflicts to help text and fixed crash with unknown cmd options
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 213
diff changeset
70 fprintf(stderr, "Unknown option -%c\n\n", arg[c]);
11
5db6178d8b58 added usage info
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
71 cmd_args_free(a);
5db6178d8b58 added usage info
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
72 return NULL;
5db6178d8b58 added usage info
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
73 }
68
f6d3db6113d3 added verbose option + encryption flag fixes
Mike Becker <universe@uap-core.de>
parents: 62
diff changeset
74 case 'v': {
f6d3db6113d3 added verbose option + encryption flag fixes
Mike Becker <universe@uap-core.de>
parents: 62
diff changeset
75 ucx_map_cstr_put(a->options, "verbose", NOARG);
f6d3db6113d3 added verbose option + encryption flag fixes
Mike Becker <universe@uap-core.de>
parents: 62
diff changeset
76 break;
f6d3db6113d3 added verbose option + encryption flag fixes
Mike Becker <universe@uap-core.de>
parents: 62
diff changeset
77 }
11
5db6178d8b58 added usage info
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
78 case 'k': {
375
39fd327f81da fixes options parser to correctly report missing arguments
Mike Becker <universe@uap-core.de>
parents: 364
diff changeset
79 option = "key";
39fd327f81da fixes options parser to correctly report missing arguments
Mike Becker <universe@uap-core.de>
parents: 364
diff changeset
80 optchar = 'k';
11
5db6178d8b58 added usage info
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
81 break;
5db6178d8b58 added usage info
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
82 }
5db6178d8b58 added usage info
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
83 case 'p': {
68
f6d3db6113d3 added verbose option + encryption flag fixes
Mike Becker <universe@uap-core.de>
parents: 62
diff changeset
84 ucx_map_cstr_put(a->options, "plain", NOARG);
11
5db6178d8b58 added usage info
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
85 break;
5db6178d8b58 added usage info
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
86 }
45
e3839719b079 added crypt command line option
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 30
diff changeset
87 case 'c': {
68
f6d3db6113d3 added verbose option + encryption flag fixes
Mike Becker <universe@uap-core.de>
parents: 62
diff changeset
88 ucx_map_cstr_put(a->options, "crypt", NOARG);
45
e3839719b079 added crypt command line option
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 30
diff changeset
89 break;
e3839719b079 added crypt command line option
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 30
diff changeset
90 }
14
d1a43035d3a2 added some options to list command
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 11
diff changeset
91 case 'a': {
68
f6d3db6113d3 added verbose option + encryption flag fixes
Mike Becker <universe@uap-core.de>
parents: 62
diff changeset
92 ucx_map_cstr_put(a->options, "all", NOARG);
14
d1a43035d3a2 added some options to list command
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 11
diff changeset
93 break;
d1a43035d3a2 added some options to list command
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 11
diff changeset
94 }
d1a43035d3a2 added some options to list command
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 11
diff changeset
95 case 'l': {
68
f6d3db6113d3 added verbose option + encryption flag fixes
Mike Becker <universe@uap-core.de>
parents: 62
diff changeset
96 ucx_map_cstr_put(a->options, "list", NOARG);
14
d1a43035d3a2 added some options to list command
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 11
diff changeset
97 break;
d1a43035d3a2 added some options to list command
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 11
diff changeset
98 }
297
3cbe57eeaed1 adds option to sort dav list by lastmodified date
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 219
diff changeset
99 case 'd': {
3cbe57eeaed1 adds option to sort dav list by lastmodified date
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 219
diff changeset
100 ucx_map_cstr_put(a->options, "date", NOARG);
3cbe57eeaed1 adds option to sort dav list by lastmodified date
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 219
diff changeset
101 break;
3cbe57eeaed1 adds option to sort dav list by lastmodified date
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 219
diff changeset
102 }
14
d1a43035d3a2 added some options to list command
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 11
diff changeset
103 case 't': {
68
f6d3db6113d3 added verbose option + encryption flag fixes
Mike Becker <universe@uap-core.de>
parents: 62
diff changeset
104 ucx_map_cstr_put(a->options, "type", NOARG);
14
d1a43035d3a2 added some options to list command
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 11
diff changeset
105 break;
d1a43035d3a2 added some options to list command
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 11
diff changeset
106 }
18
651989681053 recursive list and get
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 14
diff changeset
107 case 'R': {
68
f6d3db6113d3 added verbose option + encryption flag fixes
Mike Becker <universe@uap-core.de>
parents: 62
diff changeset
108 ucx_map_cstr_put(a->options, "recursive", NOARG);
18
651989681053 recursive list and get
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 14
diff changeset
109 break;
651989681053 recursive list and get
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 14
diff changeset
110 }
182
ca07f14f7bfe added override option for copy/move
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 119
diff changeset
111 case 'O': {
ca07f14f7bfe added override option for copy/move
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 119
diff changeset
112 ucx_map_cstr_put(a->options, "override", NOARG);
ca07f14f7bfe added override option for copy/move
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 119
diff changeset
113 break;
ca07f14f7bfe added override option for copy/move
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 119
diff changeset
114 }
199
f448fc8c9191 enabled cert verification
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 186
diff changeset
115 case 'i': {
f448fc8c9191 enabled cert verification
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 186
diff changeset
116 ucx_map_cstr_put(a->options, "insecure", NOARG);
f448fc8c9191 enabled cert verification
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 186
diff changeset
117 break;
f448fc8c9191 enabled cert verification
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 186
diff changeset
118 }
213
cd870d5f8659 added options for extended list flags and changed version output
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 212
diff changeset
119 case 'N': {
212
01e80c7cfe96 added noinput option to dav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 209
diff changeset
120 ucx_map_cstr_put(a->options, "noinput", NOARG);
01e80c7cfe96 added noinput option to dav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 209
diff changeset
121 break;
01e80c7cfe96 added noinput option to dav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 209
diff changeset
122 }
213
cd870d5f8659 added options for extended list flags and changed version output
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 212
diff changeset
123 case 'e': {
cd870d5f8659 added options for extended list flags and changed version output
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 212
diff changeset
124 ucx_map_cstr_put(a->options, "extended", NOARG);
cd870d5f8659 added options for extended list flags and changed version output
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 212
diff changeset
125 break;
cd870d5f8659 added options for extended list flags and changed version output
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 212
diff changeset
126 }
338
c7f3fe4abdb2 dav get-property supports xml property output
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 334
diff changeset
127 case 'x': {
c7f3fe4abdb2 dav get-property supports xml property output
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 334
diff changeset
128 ucx_map_cstr_put(a->options, "xml", NOARG);
c7f3fe4abdb2 dav get-property supports xml property output
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 334
diff changeset
129 break;
c7f3fe4abdb2 dav get-property supports xml property output
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 334
diff changeset
130 }
517
8531b63accae adds option to store a file info property
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 476
diff changeset
131 case 'F': {
8531b63accae adds option to store a file info property
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 476
diff changeset
132 option = "finfo";
8531b63accae adds option to store a file info property
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 476
diff changeset
133 optchar = 'F';
8531b63accae adds option to store a file info property
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 476
diff changeset
134 break;
8531b63accae adds option to store a file info property
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 476
diff changeset
135 }
309
8a474d2ad209 adds option to dav get for downloading only the directory structure
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 297
diff changeset
136 case 'S': {
8a474d2ad209 adds option to dav get for downloading only the directory structure
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 297
diff changeset
137 // undocumented hidden feature
8a474d2ad209 adds option to dav get for downloading only the directory structure
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 297
diff changeset
138 ucx_map_cstr_put(a->options, "structure", NOARG);
8a474d2ad209 adds option to dav get for downloading only the directory structure
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 297
diff changeset
139 break;
8a474d2ad209 adds option to dav get for downloading only the directory structure
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 297
diff changeset
140 }
330
54819e984a19 adds dav get option to keep existing files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 315
diff changeset
141 case 'K': {
54819e984a19 adds dav get option to keep existing files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 315
diff changeset
142 ucx_map_cstr_put(a->options, "keep", NOARG);
54819e984a19 adds dav get option to keep existing files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 315
diff changeset
143 break;
54819e984a19 adds dav get option to keep existing files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 315
diff changeset
144 }
11
5db6178d8b58 added usage info
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
145 case 'o': {
375
39fd327f81da fixes options parser to correctly report missing arguments
Mike Becker <universe@uap-core.de>
parents: 364
diff changeset
146 option = "output";
39fd327f81da fixes options parser to correctly report missing arguments
Mike Becker <universe@uap-core.de>
parents: 364
diff changeset
147 optchar = 'o';
11
5db6178d8b58 added usage info
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
148 break;
5db6178d8b58 added usage info
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
149 }
30
9a5a7a513a96 added update option for list and get
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 18
diff changeset
150 case 'u': {
375
39fd327f81da fixes options parser to correctly report missing arguments
Mike Becker <universe@uap-core.de>
parents: 364
diff changeset
151 option = "update";
39fd327f81da fixes options parser to correctly report missing arguments
Mike Becker <universe@uap-core.de>
parents: 364
diff changeset
152 optchar = 'u';
30
9a5a7a513a96 added update option for list and get
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 18
diff changeset
153 break;
9a5a7a513a96 added update option for list and get
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 18
diff changeset
154 }
62
3b813c57c106 added property-set and property-get command
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 45
diff changeset
155 case 'n': {
375
39fd327f81da fixes options parser to correctly report missing arguments
Mike Becker <universe@uap-core.de>
parents: 364
diff changeset
156 option = "namespace";
39fd327f81da fixes options parser to correctly report missing arguments
Mike Becker <universe@uap-core.de>
parents: 364
diff changeset
157 optchar = 'n';
62
3b813c57c106 added property-set and property-get command
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 45
diff changeset
158 break;
3b813c57c106 added property-set and property-get command
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 45
diff changeset
159 }
209
d24761f1e07c added lock and unlock commands to dav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 199
diff changeset
160 case 'L': {
375
39fd327f81da fixes options parser to correctly report missing arguments
Mike Becker <universe@uap-core.de>
parents: 364
diff changeset
161 option = "lock";
39fd327f81da fixes options parser to correctly report missing arguments
Mike Becker <universe@uap-core.de>
parents: 364
diff changeset
162 optchar = 'L';
209
d24761f1e07c added lock and unlock commands to dav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 199
diff changeset
163 break;
d24761f1e07c added lock and unlock commands to dav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 199
diff changeset
164 }
315
7db4dbf4e6f9 adds lock timeout
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 309
diff changeset
165 case 'T': {
375
39fd327f81da fixes options parser to correctly report missing arguments
Mike Becker <universe@uap-core.de>
parents: 364
diff changeset
166 option = "timeout";
39fd327f81da fixes options parser to correctly report missing arguments
Mike Becker <universe@uap-core.de>
parents: 364
diff changeset
167 optchar = 'T';
315
7db4dbf4e6f9 adds lock timeout
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 309
diff changeset
168 break;
7db4dbf4e6f9 adds lock timeout
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 309
diff changeset
169 }
517
8531b63accae adds option to store a file info property
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 476
diff changeset
170 /*
8531b63accae adds option to store a file info property
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 476
diff changeset
171 case 'P': {
375
39fd327f81da fixes options parser to correctly report missing arguments
Mike Becker <universe@uap-core.de>
parents: 364
diff changeset
172 option = "progressfile";
39fd327f81da fixes options parser to correctly report missing arguments
Mike Becker <universe@uap-core.de>
parents: 364
diff changeset
173 optchar = 'F';
355
5da2cf15eb44 adds primitive progress indicator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 338
diff changeset
174 break;
5da2cf15eb44 adds primitive progress indicator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 338
diff changeset
175 }
517
8531b63accae adds option to store a file info property
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 476
diff changeset
176 */
476
b4e3453e2b49 adds -V option to get, get-property and info commands
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 376
diff changeset
177 case 'V': {
b4e3453e2b49 adds -V option to get, get-property and info commands
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 376
diff changeset
178 option = "version";
b4e3453e2b49 adds -V option to get, get-property and info commands
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 376
diff changeset
179 optchar = 'V';
b4e3453e2b49 adds -V option to get, get-property and info commands
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 376
diff changeset
180 break;
b4e3453e2b49 adds -V option to get, get-property and info commands
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 376
diff changeset
181 }
11
5db6178d8b58 added usage info
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
182 }
5db6178d8b58 added usage info
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
183 }
5db6178d8b58 added usage info
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
184 } else if(option) {
5db6178d8b58 added usage info
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
185 ucx_map_cstr_put(a->options, option, arg);
5db6178d8b58 added usage info
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
186 option = NULL;
5db6178d8b58 added usage info
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
187 } else {
5db6178d8b58 added usage info
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
188 a->argv[a->argc++] = arg;
5db6178d8b58 added usage info
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
189 }
5db6178d8b58 added usage info
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
190 }
375
39fd327f81da fixes options parser to correctly report missing arguments
Mike Becker <universe@uap-core.de>
parents: 364
diff changeset
191 if(option) {
39fd327f81da fixes options parser to correctly report missing arguments
Mike Becker <universe@uap-core.de>
parents: 364
diff changeset
192 fprintf(stderr,
39fd327f81da fixes options parser to correctly report missing arguments
Mike Becker <universe@uap-core.de>
parents: 364
diff changeset
193 "Missing argument for option -%c\n\n", optchar);
39fd327f81da fixes options parser to correctly report missing arguments
Mike Becker <universe@uap-core.de>
parents: 364
diff changeset
194 cmd_args_free(a);
39fd327f81da fixes options parser to correctly report missing arguments
Mike Becker <universe@uap-core.de>
parents: 364
diff changeset
195 return NULL;
39fd327f81da fixes options parser to correctly report missing arguments
Mike Becker <universe@uap-core.de>
parents: 364
diff changeset
196 }
11
5db6178d8b58 added usage info
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
197
5db6178d8b58 added usage info
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
198 return a;
5db6178d8b58 added usage info
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
199 }
5db6178d8b58 added usage info
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
200
5db6178d8b58 added usage info
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
201 char* cmd_getoption(CmdArgs *arg, char *name) {
5db6178d8b58 added usage info
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
202 return ucx_map_cstr_get(arg->options, name);
5db6178d8b58 added usage info
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
203 }

mercurial