Browse Source

Help is always valid

Return 0 and no error, just help when the --help flag is present

Fixes https://gitlab.com/kicad/code/kicad/-/issues/21538

(cherry picked from commit 9dc76f658d)
9.0
Seth Hillbrand 2 months ago
parent
commit
40c50c94fb
  1. 16
      kicad/kicad_cli.cpp

16
kicad/kicad_cli.cpp

@ -356,7 +356,19 @@ int PGM_KICAD::OnPgmRun()
// std::runtime_error doesn't seem to be enough for the scan<>()
catch( const std::exception& err )
{
wxPrintf( "%s\n", err.what() );
bool requestedHelp = false;
for( int i = 0; i < m_argcUtf8; ++i )
{
if( std::string arg( m_argvUtf8[i] ); arg == ARG_HELP_SHORT || arg == ARG_HELP )
{
requestedHelp = true;
break;
}
}
if( !requestedHelp )
wxPrintf( "%s\n", err.what() );
// find the correct argparser object to output the command usage info
COMMAND_ENTRY* cliCmd = nullptr;
@ -378,7 +390,7 @@ int PGM_KICAD::OnPgmRun()
printHelp( argParser );
}
return CLI::EXIT_CODES::ERR_ARGS;
return requestedHelp ? 0 : CLI::EXIT_CODES::ERR_ARGS;
}
if( argParser[ ARG_HELP ] == true )

Loading…
Cancel
Save