Mercurial > sci
diff 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 |
line wrap: on
line diff
--- a/scictl/scictl.c Thu Aug 18 10:12:54 2022 +0200 +++ b/scictl/scictl.c Thu Aug 18 10:42:42 2022 +0200 @@ -185,33 +185,28 @@ static void cmd_project_update(int argc, char **argv) { - (void)argc; - (void)argv; -#if 0 - struct project pc; struct apic req; + json_t *obj; if (argc < 4) usage(); - if (apic_project_find(&req, &pc, argv[1]) < 0) + if (!(obj = apic_project_find(&req, argv[1]))) util_die("abort: unable to find project: %s\n", req.error); - if (strcmp(argv[2], "name") == 0) - replace(&pc.name, argv[3]); - else if (strcmp(argv[2], "desc") == 0) - replace(&pc.desc, argv[3]); - else if (strcmp(argv[2], "url") == 0) - replace(&pc.url, argv[3]); + /* Those fields are treated from argument. */ + if (strcmp(argv[2], "name") == 0 || + strcmp(argv[2], "desc") == 0 || + strcmp(argv[2], "url") == 0) + json_object_set_new(obj, argv[2], json_string(argv[3])); + /* The script, however, is read from the file. */ else if (strcmp(argv[2], "script") == 0) - replace(&pc.script, readfile(argv[3])); + json_object_set_new(obj, "script", json_string(readfile(argv[3]))); - if (apic_project_save(&req, &pc) < 0) + if (apic_project_save(&req, obj) < 0) util_die("abort: unable to save project: %s\n", req.error); - apic_finish(&req); - project_finish(&pc); -#endif + json_decref(obj); } static void