Add additional version info options for the cli

This commit is contained in:
Marek Roszko 2023-01-03 21:54:19 -05:00
parent a8d2f7f71d
commit 33b835ceef
1 changed files with 26 additions and 1 deletions

View File

@ -23,15 +23,40 @@
#include <wx/crt.h>
#include <kicad_build_version.h>
#include <macros.h>
#include <build_version.h>
#define ARG_FORMAT "--format"
CLI::VERSION_COMMAND::VERSION_COMMAND() : COMMAND( "version" )
{
m_argParser.add_argument( ARG_FORMAT )
.default_value( std::string( "plain" ) )
.help( UTF8STDSTR( _( "version info format (plain, commit, about)" ) ) );
}
int CLI::VERSION_COMMAND::doPerform( KIWAY& aKiway )
{
wxPrintf( KICAD_MAJOR_MINOR_PATCH_VERSION );
wxString format = FROM_UTF8( m_argParser.get<std::string>( ARG_FORMAT ).c_str() );
if( format == wxS( "plain" ) )
{
wxPrintf( KICAD_MAJOR_MINOR_PATCH_VERSION );
}
else if( format == wxS( "commit" ) )
{
wxPrintf( KICAD_COMMIT_HASH );
}
else if( format == wxS( "about" ) )
{
wxString msg_version = GetVersionInfoData( wxS( "kicad-cli" ) );
wxPrintf( msg_version );
}
else
{
wxFprintf( stderr, _( "Invalid format\n" ) );
return EXIT_CODES::ERR_ARGS;
}
return 0;
}