26#include <wx/filename.h>
28#include <wx/stdpaths.h>
29#include <wx/wxcrtvararg.h>
88 wxLogFatalError( wxT(
"Unexpected call to Kiface() in kicad/kicad.cpp" ) );
90 throw std::logic_error(
"Unexpected call to Kiface() in kicad/kicad.cpp" );
263static void printHelp( argparse::ArgumentParser& argParser )
265 std::stringstream ss;
267 wxPrintf(
FROM_UTF8( ss.str().c_str() ) );
274 App().SetAppDisplayName( wxT(
"KiCad-cli" ) );
280 wxString absoluteArgv0 = wxStandardPaths::Get().GetExecutablePath();
282 if( !wxIsAbsolutePath( absoluteArgv0 ) )
284 wxLogError( wxT(
"No meaningful argv[0]" ) );
303 argparse::ArgumentParser argParser( std::string(
"kicad-cli" ),
GetMajorMinorVersion().ToStdString(),
304 argparse::default_arguments::none );
307 .default_value(
false )
308 .help(
UTF8STDSTR(
_(
"prints version information and exits" ) ) )
309 .implicit_value(
true )
313 .default_value(
false )
315 .implicit_value(
true )
331 catch(
const std::exception& err )
333 wxPrintf(
"%s\n", err.what() );
339 if( argParser.is_subcommand_used( entry.handler->GetName() ) )
360 std::stringstream ss;
362 wxPrintf(
FROM_UTF8( ss.str().c_str() ) );
379 if( argParser.is_subcommand_used( entry.handler->GetName() ) )
382 if( cmdSubEntry !=
nullptr )
432#if defined( __WXMAC__ )
433 wxFAIL_MSG(
"kicad-cli should not call MacOpenFile" );
483#if defined( __FreeBSD__ )
485 wxLog::EnableLogging(
false );
488 return wxAppConsole::OnExit();
514 bool ProcessEvent( wxEvent& aEvent )
override
516 if( aEvent.GetEventType() == wxEVT_CHAR || aEvent.GetEventType() == wxEVT_CHAR_HOOK )
518 wxKeyEvent* keyEvent =
static_cast<wxKeyEvent*
>( &aEvent );
537 bool OnExceptionInMainLoop()
override
wxString GetMajorMinorVersion()
Get only the major and minor version in a string major.minor.
argparse::ArgumentParser & GetArgParser()
const std::string & GetName() const
int Perform(KIWAY &aKiway)
Entry point to processing commands from args and doing work.
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
virtual PROJECT & Prj() const
Return the PROJECT associated with this KIWAY.
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
Container for data for KiCad programs.
virtual wxApp & App()
Returns a bare naked wxApp which may come from wxPython, SINGLE_TOP, or kicad.exe.
int m_argcUtf8
argv parameters converted to utf8 form, because wxwidgets has opinions and will return argv as either...
std::unique_ptr< SETTINGS_MANAGER > m_settings_manager
bool InitPgm(bool aHeadless=false, bool aSkipPyInit=false, bool aIsUnitTest=false)
Initialize this program.
void BuildArgvUtf8()
Builds the UTF8 based argv variable.
void HandleException(std::exception_ptr aPtr)
A excepion handler to be used at the top level if exceptions bubble up that for.
virtual SETTINGS_MANAGER & GetSettingsManager() const
void SaveCommonSettings()
Save the program (process) settings subset which are stored .kicad_common.
PGM_KICAD extends PGM_BASE to bring in FileHistory() and PdfBrowser() which were moved from EDA_APP i...
void MacOpenFile(const wxString &aFileName) override
Specific to MacOSX (not used under Linux or Windows).
APP_SETTINGS_BASE * PgmSettings()
Container for project specific data.
T * RegisterSettings(T *aSettings, bool aLoadNow=true)
Takes ownership of the pointer passed in.
void SetKiway(KIWAY *aKiway)
Associate this setting manager with the given Kiway.
#define KICAD_CLI_APP_NAME
const wxChar *const kicadTraceKeyEvent
Flag to enable wxKeyEvent debug tracing.
static CLI::EXPORT_PCB_POS_COMMAND exportPcbPosCmd
static CLI::EXPORT_SCH_PLOT_COMMAND exportSchSvgCmd
static CLI::EXPORT_PCB_PDF_COMMAND exportPcbPdfCmd
static CLI::EXPORT_PCB_DXF_COMMAND exportPcbDxfCmd
static CLI::EXPORT_SCH_COMMAND exportSchCmd
static CLI::EXPORT_SCH_PLOT_COMMAND exportSchHpglCmd
static CLI::FP_EXPORT_SVG_COMMAND fpExportSvgCmd
static CLI::SYM_UPGRADE_COMMAND symUpgradeCmd
static CLI::FP_EXPORT_COMMAND fpExportCmd
static CLI::FP_UPGRADE_COMMAND fpUpgradeCmd
static void printHelp(argparse::ArgumentParser &argParser)
static CLI::EXPORT_SCH_PLOT_COMMAND exportSchDxfCmd
static CLI::EXPORT_PCB_GERBER_COMMAND exportPcbGerberCmd
static CLI::EXPORT_PCB_COMMAND exportPcbCmd
static CLI::EXPORT_SCH_NETLIST_COMMAND exportSchNetlistCmd
static CLI::EXPORT_PCB_DRILL_COMMAND exportPcbDrillCmd
static CLI::SYM_COMMAND symCmd
static CLI::EXPORT_PCB_GERBERS_COMMAND exportPcbGerbersCmd
static CLI::EXPORT_SCH_PLOT_COMMAND exportSchPdfCmd
static CLI::EXPORT_PCB_STEP_COMMAND exportPcbStepCmd
static CLI::EXPORT_PCB_SVG_COMMAND exportPcbSvgCmd
static CLI::EXPORT_SCH_PYTHONBOM_COMMAND exportSchPythonBomCmd
static CLI::SCH_COMMAND schCmd
static CLI::PCB_COMMAND pcbCmd
static std::vector< COMMAND_ENTRY > commandStack
static CLI::SYM_EXPORT_COMMAND symExportCmd
static CLI::EXPORT_SCH_PLOT_COMMAND exportSchPostscriptCmd
static CLI::SYM_EXPORT_SVG_COMMAND symExportSvgCmd
static COMMAND_ENTRY * recurseArgParserSubCommandUsed(argparse::ArgumentParser &aArgParser, COMMAND_ENTRY &aEntry)
static CLI::EXPORT_SCH_BOM_COMMAND exportSchBomCmd
PGM_BASE & Pgm()
The global Program "get" accessor.
KIFACE_BASE & Kiface()
Global KIFACE_BASE "get" accessor.
static CLI::VERSION_COMMAND versionCmd
PGM_BASE * PgmOrNull()
similar to PGM_BASE& Pgm(), but return a reference that can be nullptr when running a shared lib from...
static void recurseArgParserBuild(argparse::ArgumentParser &aArgParser, COMMAND_ENTRY &aEntry)
static CLI::FP_COMMAND fpCmd
#define KFCTL_CPP_PROJECT_SUITE
Running under C++ project mgr, possibly with others.
#define KFCTL_CLI
Running as CLI app.
This file contains miscellaneous commonly used macros and functions.
static wxString FROM_UTF8(const char *cstring)
Convert a UTF8 encoded C string to a wxString for all wxWidgets build modes.
static const int ERR_ARGS
static const int AVOID_CLOSING
std::vector< FAB_LAYER_COLOR > dummy
Not publicly visible because most of the action is in PGM_KICAD these days.
int FilterEvent(wxEvent &aEvent) override
void InitSettings(APP_SETTINGS_BASE *aPtr)
Takes ownership of a new application settings object.
COMMAND_ENTRY(CLI::COMMAND *aHandler)
COMMAND_ENTRY(CLI::COMMAND *aHandler, std::vector< COMMAND_ENTRY > aSub)
std::vector< COMMAND_ENTRY > subCommands
System directories search utilities.
wxString dump(const wxArrayString &aArray)
Debug helper for printing wxArrayString contents.
wxLogTrace helper definitions.