Zebediah Figura : vkd3d-compiler: Print usage instructions only if --help is specified.

Alexandre Julliard julliard at winehq.org
Thu Jan 6 18:30:41 CST 2022


Module: vkd3d
Branch: master
Commit: 1e2bcb04581506892f5b1c5c7687f1aac58b6467
URL:    https://source.winehq.org/git/vkd3d.git/?a=commit;h=1e2bcb04581506892f5b1c5c7687f1aac58b6467

Author: Zebediah Figura <zfigura at codeweavers.com>
Date:   Sat Dec 25 22:43:12 2021 -0600

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 <zfigura at codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
Signed-off-by: Giovanni Mascellani <gmascellani at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 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 4d7d628..4e56e8f 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)




More information about the wine-cvs mailing list