diff --git a/cognac_gen.sh b/cognac_gen.sh index 0d870d5..5efa7de 100755 --- a/cognac_gen.sh +++ b/cognac_gen.sh @@ -346,7 +346,7 @@ EOF goto ${snake_l}_arg; } - if (i + 1 < ac && av[i + 1][0] == '-' && av[i + 1][1] == '-' && strcmp(av[i + 1] + 2, "SetVar")) { + if (i + 1 < ac && av[i + 1][0] == '-' && av[i + 1][1] == '-' && strcmp(av[i + 1] + 2, "set-var")) { char *next_a = &av[i + 1][2]; char *str = next_a; char *aa = i + 2 < ac ? av[i + 2] : 0; @@ -419,9 +419,9 @@ EOF JSON_C_TO_STRING_PRETTY | JSON_C_TO_STRING_NOSLASHESCAPE | color_flag)); } - if (i + 1 < ac && !strcmp(av[i + 1], "--SetVar")) { + if (i + 1 < ac && !strcmp(av[i + 1], "--set-var")) { ++i; - TRY(i + 1 >= ac, "--SetVar require an argument"); + TRY(i + 1 >= ac, "--set-var require an argument"); if (!jobj) jobj = json_tokener_parse(r.buf); if (parse_variable(jobj, av, ac, i)) diff --git a/main_tpl.c b/main_tpl.c index 5feaba1..699fb6f 100644 --- a/main_tpl.c +++ b/main_tpl.c @@ -365,7 +365,7 @@ int main(int ac, char **av) if (ac < 2 || (ac == 2 && !strcmp(av[1], "--help"))) { show_help: - printf("Usage: %s [--help] CallName [options] [--Params >]\n" + printf("Usage: %s [--help] CallName [options] [--Params >] | --var \n" "options:\n" "\t --auth-method=METHODE set authentification method, password|accesskey|none\n" "\t --color try to colorize json if json-c support it\n" @@ -373,6 +373,10 @@ int main(int ac, char **av) "\t --file PATH use content of PATH as an agrument for a call, example:\n" "\t\t\t\toapi-cli CreateCa --CaPem --file /$CA_DIR/cert.pem\n" "\t --jsonstr-file PATH same as --file, except the content is surrounded by \"\n" + "\t --set-var ID=VARIABLE_PATH Create an oapi-cli variable, that can be use with --var\n" + "\t\t\t\tExamples: ./oapi-cli ReadVms --Filters.TagValues[] VM_NAME --set-var id=Vms.0.VmId ReadVms --Filters.VmIds[] --var id\n" + "\t\t\t\twill find the vm with VM_NAME as it's tag, and read it again, but using it's VmId as filter this time\n" + "\t --var use variabble content created by --set-var\n" "\t\t\t\tand \" inside the file are escape with a \\, this option is useful for CreatePolicy\n" "\t-h, --help [CallName] this, can be used with call name, example:\n\t\t\t\t%s --help ReadVms\n" "\t --list-calls list all calls\n"