Commit 9eac6cae authored by Malenovsky, Vladimir's avatar Malenovsky, Vladimir
Browse files

improve command-line parameter error messages

parent b10c0a89
Loading
Loading
Loading
Loading
Loading
+39 −9
Original line number Diff line number Diff line
@@ -523,17 +523,22 @@ static int16_t parseOption(
            strncpy( args->inMetadataFilePath, optionValues[0], POST_REND_MAX_CLI_ARG_LENGTH - 1 );
            break;
        case CmdLnOptionId_outputFile:
            if ( numOptionValues != 1 )
            if ( numOptionValues == 0 )
            {
                fprintf( stderr, "Error: No output file has been provided!\n" );
                return -1;
            }
            else if ( numOptionValues > 1 )
            {
                fprintf( stderr, "Error: The program expects a single output file, but %d have been provided!\n", numOptionValues );
                return -1;
            }
            strncpy( args->outputFilePath, optionValues[0], POST_REND_MAX_CLI_ARG_LENGTH - 1 );
            break;
        case CmdLnOptionId_sampleRate:
            if ( numOptionValues != 1 )
            {
                fprintf( stderr, "Error: Incorrect input sampling rate has been provided!\n" );
                fprintf( stderr, "Error: Incorrect sampling rate specification!\n" );
                return -1;
            }
            args->sampleRate = (int32_t) ( strtol( optionValues[0], NULL, 10 ) * 1000 );
@@ -544,27 +549,42 @@ static int16_t parseOption(
            }
            break;
        case CmdLnOptionId_trajFile:
            if ( numOptionValues != 1 )
            if ( numOptionValues == 0 )
            {
                fprintf( stderr, "Error: No head rotation trajectory file has been provided!\n" );
                return -1;
            }
            else if ( numOptionValues > 1 )
            {
                fprintf( stderr, "Error: The program expects a single head rotation trajectory file, but %d have been provided!\n", numOptionValues );
                return -1;
            }
            strncpy( args->headRotationFilePath, optionValues[0], POST_REND_MAX_CLI_ARG_LENGTH - 1 );
            break;
        case CmdLnOptionId_SplitRendBFIFile:
            if ( numOptionValues != 1 )
            if ( numOptionValues == 0 )
            {
                fprintf( stderr, "Error: No BFI file has been provided!\n" );
                return -1;
            }
            else if ( numOptionValues > 1 )
            {
                fprintf( stderr, "Error: No bfi file has been provided!\n" );
                fprintf( stderr, "Error: The program expects a single BFI file, but %d have been provided!\n", numOptionValues );
                return -1;
            }
            strncpy( args->splitRendBFIFilePath, optionValues[0], POST_REND_MAX_CLI_ARG_LENGTH - 1 );
            break;
        case CmdLnOptionId_complexityLevel:
            if ( numOptionValues != 1 )
            if ( numOptionValues == 0 )
            {
                fprintf( stderr, "Error: No complexity level has been provided!\n" );
                return -1;
            }
            else if ( numOptionValues > 1 )
            {
                fprintf( stderr, "Error: The program expects a single complexity level, but %d have been provided!\n", numOptionValues );
                return -1;
            }
            args->complexityLevel = (int32_t) ( strtol( optionValues[0], NULL, 10 ) );
            if ( args->complexityLevel < ISAR_POST_REND_COMPLEXITY_LEVEL_ONE || args->complexityLevel > ISAR_POST_REND_COMPLEXITY_LEVEL_THREE )
            {
@@ -593,11 +613,16 @@ static int16_t parseOption(
            args->quietModeEnabled = true;
            break;
        case CmdLnOptionId_framing:
            if ( numOptionValues != 1 )
            if ( numOptionValues == 0 )
            {
                fprintf( stderr, "Error: Incorrect audio rendering frame size!\n" );
                return -1;
            }
            else if ( numOptionValues > 1 )
            {
                fprintf( stderr, "Error: The program expects a rendering frame size, but %d have been provided!\n", numOptionValues );
                return -1;
            }
            if ( !parseRenderFramesize( optionValues[0], &args->render_framesize ) )
            {
                fprintf( stderr, "Error: Unknown or invalid option for audio rendring frame size: %s\n", optionValues[0] );
@@ -605,9 +630,14 @@ static int16_t parseOption(
            }
            break;
        case CmdLnOptionId_srParamsFile:
            if ( numOptionValues != 1 )
            if ( numOptionValues == 0 )
            {
                fprintf( stderr, "Error: No path to the parameter initialization file has been provided!\n" );
                return -1;
            }
            else if ( numOptionValues > 1 )
            {
                fprintf( stderr, "Error: No path to split rending init params file has been provided!\n" );
                fprintf( stderr, "Error: The program expects a single parameter initialization file, but %d have been provided!\n", numOptionValues );
                return -1;
            }
            strncpy( args->srParamsFilePath, optionValues[0], POST_REND_MAX_CLI_ARG_LENGTH - 1 );