Skip to content

Commit

Permalink
Make C usage printout more similar to python usage printout
Browse files Browse the repository at this point in the history
  • Loading branch information
eriknyquist committed Nov 4, 2023
1 parent 2e9f0a8 commit 91282ff
Show file tree
Hide file tree
Showing 11 changed files with 56 additions and 56 deletions.
2 changes: 1 addition & 1 deletion duckargs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ def _generate_c_usage_code(processed_args):
arg = None
right_col = ""
if opt.is_flag():
right_col = "A flag\\n\""
right_col = f"{opt.desc} flag\\n\""
else:
if type(opt.value) == list:
right_col = f"A string value (default: %s)\\n\", {opt.var_name} ? {opt.var_name} : \"null\""
Expand Down
4 changes: 2 additions & 2 deletions tests/test_data/choices/expected_c.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ void print_usage(void)
printf("USAGE:\n\n");
printf("program_name [OPTIONS] pos1 pos2\n");
printf("\nOPTIONS:\n\n");
printf("-f A flag\n");
printf("-g A flag\n");
printf("-f f flag\n");
printf("-g g flag\n");
printf("-q --qefqaf [op|ep|orp] A string value (default: %s)\n", qefqaf ? qefqaf : "null");
printf("\n");
}
Expand Down
6 changes: 3 additions & 3 deletions tests/test_data/env_all/expected_c.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ void print_usage(void)
printf("-e [float] A float value (default: %.2f)\n", e);
printf("-f --file FILE A filename (default: %s)\n", file ? file : "null");
printf("-F --otherfile FILE A filename (default: %s)\n", otherfile ? otherfile : "null");
printf("-a A flag\n");
printf("-b A flag\n");
printf("-c A flag\n");
printf("-a a flag\n");
printf("-b b flag\n");
printf("-c c flag\n");
printf("\n");
}

Expand Down
6 changes: 3 additions & 3 deletions tests/test_data/env_comment/expected_c.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ void print_usage(void)
printf("-e [float] A float value (default: %.2f)\n", e);
printf("-f --file FILE A filename (default: %s)\n", file ? file : "null");
printf("-F --otherfile FILE A filename (default: %s)\n", otherfile ? otherfile : "null");
printf("-a A flag\n");
printf("-b A flag\n");
printf("-c A flag\n");
printf("-a a flag\n");
printf("-b b flag\n");
printf("-c c flag\n");
printf("\n");
}

Expand Down
6 changes: 3 additions & 3 deletions tests/test_data/env_print/expected_c.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ void print_usage(void)
printf("-e [float] A float value (default: %.2f)\n", e);
printf("-f --file FILE A filename (default: %s)\n", file ? file : "null");
printf("-F --otherfile FILE A filename (default: %s)\n", otherfile ? otherfile : "null");
printf("-a A flag\n");
printf("-b A flag\n");
printf("-c A flag\n");
printf("-a a flag\n");
printf("-b b flag\n");
printf("-c c flag\n");
printf("\n");
}

Expand Down
16 changes: 8 additions & 8 deletions tests/test_data/flags_only/expected_c.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ void print_usage(void)
printf("USAGE:\n\n");
printf("program_name [OPTIONS]\n");
printf("\nOPTIONS:\n\n");
printf("-a A flag\n");
printf("-b A flag\n");
printf("-c A flag\n");
printf("-d A flag\n");
printf("-e A flag\n");
printf("-f A flag\n");
printf("-g A flag\n");
printf("-h A flag\n");
printf("-a a flag\n");
printf("-b b flag\n");
printf("-c c flag\n");
printf("-d d flag\n");
printf("-e e flag\n");
printf("-f f flag\n");
printf("-g g flag\n");
printf("-h h flag\n");
printf("\n");
}

Expand Down
16 changes: 8 additions & 8 deletions tests/test_data/many_opts/expected_c.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,20 +55,20 @@ void print_usage(void)
printf("program_name [OPTIONS] pos1 pos2 pos3 pos4 pos5 pos6 pos7 pos8 pos9 pos10\n");
printf("\nOPTIONS:\n\n");
printf("-a --aye [int] An int value (default: %ld)\n", aye);
printf("-w --yyy A flag\n");
printf("-w --yyy yyy flag\n");
printf("-k [float] A float value (default: %.2f)\n", k);
printf("-l [string] A string value (default: %s)\n", l ? l : "null");
printf("-o --out A flag\n");
printf("-d --ede A flag\n");
printf("-o --out out flag\n");
printf("-d --ede ede flag\n");
printf("-v --vvv [string] A string value (default: %s)\n", vvv ? vvv : "null");
printf("-s --ssss A flag\n");
printf("-z --zzzz A flag\n");
printf("-s --ssss ssss flag\n");
printf("-z --zzzz zzzz flag\n");
printf("-c --ccc [string] A string value (default: %s)\n", ccc ? ccc : "null");
printf("-b --bbb [int] An int value (default: %ld)\n", bbb);
printf("-i --ii [string] A string value (default: %s)\n", ii ? ii : "null");
printf("-q --qqqqsdgvs A flag\n");
printf("-y A flag\n");
printf("-r A flag\n");
printf("-q --qqqqsdgvs qqqqsdgvs flag\n");
printf("-y y flag\n");
printf("-r r flag\n");
printf("\n");
}

Expand Down
2 changes: 1 addition & 1 deletion tests/test_data/normalize_names/expected_c.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ void print_usage(void)
printf("\nOPTIONS:\n\n");
printf("-a --test_1 [int] An int value (default: %ld)\n", test_1);
printf("-b --test__-2 [int] An int value (default: %ld)\n", test___2);
printf("-j --j--j A flag\n");
printf("-j --j--j j__j flag\n");
printf("-g --lp--l [string] A string value (default: %s)\n", lp__l ? lp__l : "null");
printf("\n");
}
Expand Down
6 changes: 3 additions & 3 deletions tests/test_data/readme_example/expected_c.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ void print_usage(void)
printf("-e [float] A float value (default: %.2f)\n", e);
printf("-f --file FILE A filename (default: %s)\n", file ? file : "null");
printf("-F --otherfile FILE A filename (default: %s)\n", otherfile ? otherfile : "null");
printf("-a A flag\n");
printf("-b A flag\n");
printf("-c A flag\n");
printf("-a a flag\n");
printf("-b b flag\n");
printf("-c c flag\n");
printf("\n");
}

Expand Down
26 changes: 13 additions & 13 deletions tests/test_data/reserved_words_c/expected_c.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,19 +50,19 @@ void print_usage(void)
printf("\nOPTIONS:\n\n");
printf("-i --int [int] An int value (default: %ld)\n", intval);
printf("-f --float [float] A float value (default: %.2f)\n", floatval);
printf("-s --struct A flag\n");
printf("-v --void A flag\n");
printf("-q --for A flag\n");
printf("-b --break A flag\n");
printf("-r --return A flag\n");
printf("-a --auto A flag\n");
printf("-p --static A flag\n");
printf("-w --while A flag\n");
printf("-o --switch A flag\n");
printf("-t --typedef A flag\n");
printf("-k --double A flag\n");
printf("-x --signed A flag\n");
printf("-e --const A flag\n");
printf("-s --struct struct flag\n");
printf("-v --void void flag\n");
printf("-q --for for flag\n");
printf("-b --break break flag\n");
printf("-r --return return flag\n");
printf("-a --auto auto flag\n");
printf("-p --static static flag\n");
printf("-w --while while flag\n");
printf("-o --switch switch flag\n");
printf("-t --typedef typedef flag\n");
printf("-k --double double flag\n");
printf("-x --signed signed flag\n");
printf("-e --const const flag\n");
printf("\n");
}

Expand Down
22 changes: 11 additions & 11 deletions tests/test_data/reserved_words_python/expected_c.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,17 @@ void print_usage(void)
printf("\nOPTIONS:\n\n");
printf("-i --int [int] An int value (default: %ld)\n", intval);
printf("-f --float [float] A float value (default: %.2f)\n", floatval);
printf("-d --dict A flag\n");
printf("-t --tuple A flag\n");
printf("-r --return A flag\n");
printf("-l --lambda A flag\n");
printf("-n --nonlocal A flag\n");
printf("-q --from A flag\n");
printf("-c --continue A flag\n");
printf("-y --yield A flag\n");
printf("-g --global A flag\n");
printf("-u --del A flag\n");
printf("-b --class A flag\n");
printf("-d --dict dict flag\n");
printf("-t --tuple tuple flag\n");
printf("-r --return return flag\n");
printf("-l --lambda lambda flag\n");
printf("-n --nonlocal nonlocal flag\n");
printf("-q --from from flag\n");
printf("-c --continue continue flag\n");
printf("-y --yield yield flag\n");
printf("-g --global global flag\n");
printf("-u --del del flag\n");
printf("-b --class class flag\n");
printf("\n");
}

Expand Down

0 comments on commit 91282ff

Please sign in to comment.