From 1e2bcb04581506892f5b1c5c7687f1aac58b6467 Mon Sep 17 00:00:00 2001 From: Zebediah Figura Date: Sat, 25 Dec 2021 22:43:12 -0600 Subject: [PATCH] vkd3d-compiler: Print usage instructions only if --help is specified. vkd3d-compiler is hardly the only program to print usage instructions on all invalid invocations, but it's rather annoying to have one's whole screen wiped due to a typo. It also makes it hard to notice the actual error messages printed on e.g. `vkd3d-compiler -x`. Signed-off-by: Zebediah Figura Signed-off-by: Henri Verbeet Signed-off-by: Giovanni Mascellani Signed-off-by: Alexandre Julliard --- programs/vkd3d-compiler/main.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/programs/vkd3d-compiler/main.c b/programs/vkd3d-compiler/main.c index 4d7d628c..4e56e8fa 100644 --- a/programs/vkd3d-compiler/main.c +++ b/programs/vkd3d-compiler/main.c @@ -209,6 +209,7 @@ struct options enum vkd3d_shader_source_type source_type; enum vkd3d_shader_target_type target_type; bool preprocess_only; + bool print_help; bool print_version; bool print_source_types; bool print_target_types; @@ -446,6 +447,11 @@ static bool parse_command_line(int argc, char **argv, struct options *options) options->preprocess_only = true; break; + case 'h': + case OPTION_HELP: + options->print_help = true; + return true; + case OPTION_OUTPUT: case 'o': options->output_filename = optarg; @@ -623,9 +629,12 @@ int main(int argc, char **argv) int ret; if (!parse_command_line(argc, argv, &options)) + return 1; + + if (options.print_help) { print_usage(argv[0]); - return 1; + return 0; } if (options.print_version)