Mercurial > sci
comparison scictl/scictl.c @ 61:8be8188d61a5
scictl: resurrect project-update command
author | David Demelier <markand@malikania.fr> |
---|---|
date | Thu, 18 Aug 2022 10:42:42 +0200 |
parents | 319979427566 |
children | 67470b67e460 |
comparison
equal
deleted
inserted
replaced
60:3804a2ab60ec | 61:8be8188d61a5 |
---|---|
183 } | 183 } |
184 | 184 |
185 static void | 185 static void |
186 cmd_project_update(int argc, char **argv) | 186 cmd_project_update(int argc, char **argv) |
187 { | 187 { |
188 (void)argc; | 188 struct apic req; |
189 (void)argv; | 189 json_t *obj; |
190 #if 0 | |
191 struct project pc; | |
192 struct apic req; | |
193 | 190 |
194 if (argc < 4) | 191 if (argc < 4) |
195 usage(); | 192 usage(); |
196 | 193 |
197 if (apic_project_find(&req, &pc, argv[1]) < 0) | 194 if (!(obj = apic_project_find(&req, argv[1]))) |
198 util_die("abort: unable to find project: %s\n", req.error); | 195 util_die("abort: unable to find project: %s\n", req.error); |
199 | 196 |
200 if (strcmp(argv[2], "name") == 0) | 197 /* Those fields are treated from argument. */ |
201 replace(&pc.name, argv[3]); | 198 if (strcmp(argv[2], "name") == 0 || |
202 else if (strcmp(argv[2], "desc") == 0) | 199 strcmp(argv[2], "desc") == 0 || |
203 replace(&pc.desc, argv[3]); | 200 strcmp(argv[2], "url") == 0) |
204 else if (strcmp(argv[2], "url") == 0) | 201 json_object_set_new(obj, argv[2], json_string(argv[3])); |
205 replace(&pc.url, argv[3]); | 202 /* The script, however, is read from the file. */ |
206 else if (strcmp(argv[2], "script") == 0) | 203 else if (strcmp(argv[2], "script") == 0) |
207 replace(&pc.script, readfile(argv[3])); | 204 json_object_set_new(obj, "script", json_string(readfile(argv[3]))); |
208 | 205 |
209 if (apic_project_save(&req, &pc) < 0) | 206 if (apic_project_save(&req, obj) < 0) |
210 util_die("abort: unable to save project: %s\n", req.error); | 207 util_die("abort: unable to save project: %s\n", req.error); |
211 | 208 |
212 apic_finish(&req); | 209 json_decref(obj); |
213 project_finish(&pc); | |
214 #endif | |
215 } | 210 } |
216 | 211 |
217 static void | 212 static void |
218 cmd_project_info(int argc, char **argv) | 213 cmd_project_info(int argc, char **argv) |
219 { | 214 { |