[PATCH vkd3d v3 1/3] vkd3d-compiler: Print usage instructions only if --help is specified.

Giovanni Mascellani gmascellani at codeweavers.com
Tue Jan 4 07:23:55 CST 2022


Signed-off-by: Giovanni Mascellani <gmascellani at codeweavers.com>

On 26/12/21 05:43, Zebediah Figura wrote:
> 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>
> ---
>   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 4d7d628ca..4e56e8fa5 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-devel mailing list