From 33b835ceefaa9349c596c50760495ebe17ac02ca Mon Sep 17 00:00:00 2001 From: Marek Roszko Date: Tue, 3 Jan 2023 21:54:19 -0500 Subject: [PATCH] Add additional version info options for the cli --- kicad/cli/command_version.cpp | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/kicad/cli/command_version.cpp b/kicad/cli/command_version.cpp index e4ef5db8f2..0067563ad0 100644 --- a/kicad/cli/command_version.cpp +++ b/kicad/cli/command_version.cpp @@ -23,15 +23,40 @@ #include #include +#include +#include + +#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( 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; } \ No newline at end of file