Commit 9a7751d4 authored by Vladimir Malenovsky's avatar Vladimir Malenovsky
Browse files

print mandatory options as part of Usage: ... string

parent 76795b39
Loading
Loading
Loading
Loading
Loading
+22 −4
Original line number Diff line number Diff line
@@ -442,10 +442,6 @@ static void printUsage(
    const OptionProps *optionProps,
    const int32_t numOptions )
{
    fprintf( stderr, "\n" );
    fprintf( stderr, "Usage: %s [options]\n", getBasename( argv0 ) );
    fprintf( stderr, "\n" );

    int32_t numOptChars;
    int32_t maxNumOptChars = 0;
    bool hasMandatoryOptions = false;
@@ -465,6 +461,28 @@ static void printUsage(
        }
    }

    fprintf( stderr, "\n" );
    fprintf( stderr, "Usage: %s [options]", getBasename( argv0 ) );
    for ( int32_t i = 0; i < numOptions; ++i )
    {
        OptionProps opt = optionProps[i];

        if ( opt.isMandatory )
        {
            if (!isEmptyString(opt.matchShort))
            {
                fprintf( stderr, " -%s", opt.matchShort );
            }

            if ( !isEmptyString( opt.placeholder ) )
            {
                fprintf( stderr, " %s", opt.placeholder );
            }
        }
    }

    fprintf( stderr, "\n\n" );

    if ( hasMandatoryOptions )
    {
        fprintf( stderr, "Mandatory parameters:\n---------------------\n" );