Skip to content

Commit

Permalink
add help for -set-var/-var
Browse files Browse the repository at this point in the history
Signed-off-by: Matthias Gatto <[email protected]>
  • Loading branch information
outscale-mgo committed Apr 11, 2024
1 parent 865a856 commit f7cb24c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 3 additions & 3 deletions cognac_gen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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))
Expand Down
6 changes: 5 additions & 1 deletion main_tpl.c
Original file line number Diff line number Diff line change
Expand Up @@ -365,14 +365,18 @@ int main(int ac, char **av)

if (ac < 2 || (ac == 2 && !strcmp(av[1], "--help"))) {
show_help:
printf("Usage: %s [--help] CallName [options] [--Params <param_argument | [--file | --jsonstr-file] <file_name>>]\n"
printf("Usage: %s [--help] CallName [options] [--Params <param_argument | [--file | --jsonstr-file] <file_name>>] | --var <variable_name>\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"
"\t --config=PATH config file path\n"
"\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"
Expand Down

0 comments on commit f7cb24c

Please sign in to comment.