diff --git a/duckargs/__init__.py b/duckargs/__init__.py index f4d22db..18f6bb6 100644 --- a/duckargs/__init__.py +++ b/duckargs/__init__.py @@ -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\"" diff --git a/tests/test_data/choices/expected_c.txt b/tests/test_data/choices/expected_c.txt index 122255b..173a52a 100644 --- a/tests/test_data/choices/expected_c.txt +++ b/tests/test_data/choices/expected_c.txt @@ -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"); } diff --git a/tests/test_data/env_all/expected_c.txt b/tests/test_data/env_all/expected_c.txt index 8e980a1..961fd4a 100644 --- a/tests/test_data/env_all/expected_c.txt +++ b/tests/test_data/env_all/expected_c.txt @@ -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"); } diff --git a/tests/test_data/env_comment/expected_c.txt b/tests/test_data/env_comment/expected_c.txt index f0609c0..1d13113 100644 --- a/tests/test_data/env_comment/expected_c.txt +++ b/tests/test_data/env_comment/expected_c.txt @@ -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"); } diff --git a/tests/test_data/env_print/expected_c.txt b/tests/test_data/env_print/expected_c.txt index d6dcb75..d29408e 100644 --- a/tests/test_data/env_print/expected_c.txt +++ b/tests/test_data/env_print/expected_c.txt @@ -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"); } diff --git a/tests/test_data/flags_only/expected_c.txt b/tests/test_data/flags_only/expected_c.txt index 9e2a038..16c2922 100644 --- a/tests/test_data/flags_only/expected_c.txt +++ b/tests/test_data/flags_only/expected_c.txt @@ -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"); } diff --git a/tests/test_data/many_opts/expected_c.txt b/tests/test_data/many_opts/expected_c.txt index 008eb61..c337bb0 100644 --- a/tests/test_data/many_opts/expected_c.txt +++ b/tests/test_data/many_opts/expected_c.txt @@ -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"); } diff --git a/tests/test_data/normalize_names/expected_c.txt b/tests/test_data/normalize_names/expected_c.txt index 637d903..08b799d 100644 --- a/tests/test_data/normalize_names/expected_c.txt +++ b/tests/test_data/normalize_names/expected_c.txt @@ -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"); } diff --git a/tests/test_data/readme_example/expected_c.txt b/tests/test_data/readme_example/expected_c.txt index 74f3712..e2d32a8 100644 --- a/tests/test_data/readme_example/expected_c.txt +++ b/tests/test_data/readme_example/expected_c.txt @@ -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"); } diff --git a/tests/test_data/reserved_words_c/expected_c.txt b/tests/test_data/reserved_words_c/expected_c.txt index 969f9c5..6eedd7e 100644 --- a/tests/test_data/reserved_words_c/expected_c.txt +++ b/tests/test_data/reserved_words_c/expected_c.txt @@ -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"); } diff --git a/tests/test_data/reserved_words_python/expected_c.txt b/tests/test_data/reserved_words_python/expected_c.txt index 4a7a158..412b923 100644 --- a/tests/test_data/reserved_words_python/expected_c.txt +++ b/tests/test_data/reserved_words_python/expected_c.txt @@ -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"); }