26#include <wx/filename.h>
28#include <wx/stdpaths.h>
29#include <wx/wxcrtvararg.h>
94 wxLogFatalError( wxT(
"Unexpected call to Kiface() in kicad/kicad.cpp" ) );
96 throw std::logic_error(
"Unexpected call to Kiface() in kicad/kicad.cpp" );
284static void printHelp( argparse::ArgumentParser& argParser )
286 std::stringstream ss;
288 wxPrintf(
From_UTF8( ss.str().c_str() ) );
295 App().SetAppDisplayName( wxT(
"kicad-cli" ) );
298 wxString absoluteArgv0 = wxStandardPaths::Get().GetExecutablePath();
300 if( !wxIsAbsolutePath( absoluteArgv0 ) )
302 wxLogError( wxT(
"No meaningful argv[0]" ) );
321 argparse::ArgumentParser argParser( std::string(
"kicad-cli" ),
GetMajorMinorVersion().ToStdString(),
322 argparse::default_arguments::none );
325 .default_value(
false )
326 .help(
UTF8STDSTR(
_(
"prints version information and exits" ) ) )
327 .implicit_value(
true )
331 .default_value(
false )
333 .implicit_value(
true )
349 catch(
const std::exception& err )
351 wxPrintf(
"%s\n", err.what() );
357 if( argParser.is_subcommand_used( entry.handler->GetName() ) )
378 std::stringstream ss;
380 wxPrintf(
From_UTF8( ss.str().c_str() ) );
397 if( argParser.is_subcommand_used( entry.handler->GetName() ) )
400 if( cmdSubEntry !=
nullptr )
450#if defined( __WXMAC__ )
451 wxFAIL_MSG(
"kicad-cli should not call MacOpenFile" );
495 if( wxGetEnv( wxS(
"KICAD_ENABLE_WXTRACE" ),
nullptr ) )
497 wxLog::EnableLogging(
true );
498 wxLog::SetLogLevel( wxLOG_Trace );
515#if defined( __FreeBSD__ )
517 wxLog::EnableLogging(
false );
520 return wxAppConsole::OnExit();
546 bool ProcessEvent( wxEvent& aEvent )
override
548 if( aEvent.GetEventType() == wxEVT_CHAR || aEvent.GetEventType() == wxEVT_CHAR_HOOK )
550 wxKeyEvent* keyEvent =
static_cast<wxKeyEvent*
>( &aEvent );
569 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.
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 exception 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.
const wxChar *const kicadTraceKeyEvent
Flag to enable wxKeyEvent debug tracing.
static CLI::PCB_EXPORT_SVG_COMMAND exportPcbSvgCmd
static CLI::SCH_EXPORT_PLOT_COMMAND exportSchHpglCmd
static CLI::SCH_EXPORT_PLOT_COMMAND exportSchSvgCmd
static CLI::PCB_EXPORT_3D_COMMAND exportPcbVrmlCmd
static CLI::PCB_EXPORT_DXF_COMMAND exportPcbDxfCmd
static CLI::SCH_ERC_COMMAND schErcCmd
static CLI::PCB_DRC_COMMAND pcbDrcCmd
static CLI::PCB_EXPORT_GERBER_COMMAND exportPcbGerberCmd
static CLI::FP_EXPORT_SVG_COMMAND fpExportSvgCmd
static CLI::PCB_EXPORT_COMMAND exportPcbCmd
static CLI::PCB_RENDER_COMMAND pcbRenderCmd
static CLI::SYM_UPGRADE_COMMAND symUpgradeCmd
static CLI::FP_EXPORT_COMMAND fpExportCmd
static CLI::SCH_EXPORT_PYTHONBOM_COMMAND exportSchPythonBomCmd
static CLI::FP_UPGRADE_COMMAND fpUpgradeCmd
static CLI::SCH_EXPORT_PLOT_COMMAND exportSchPdfCmd
static void printHelp(argparse::ArgumentParser &argParser)
static CLI::JOBSET_RUN_COMMAND jobsetRunCmd
static CLI::PCB_EXPORT_POS_COMMAND exportPcbPosCmd
static CLI::SYM_COMMAND symCmd
static CLI::PCB_EXPORT_3D_COMMAND exportPcbStepCmd
static CLI::PCB_EXPORT_3D_COMMAND exportPcbPlyCmd
static CLI::PCB_EXPORT_GERBERS_COMMAND exportPcbGerbersCmd
static CLI::SCH_EXPORT_BOM_COMMAND exportSchBomCmd
static CLI::SCH_COMMAND schCmd
static CLI::PCB_COMMAND pcbCmd
static std::vector< COMMAND_ENTRY > commandStack
static CLI::PCB_EXPORT_DRILL_COMMAND exportPcbDrillCmd
static CLI::PCB_EXPORT_IPC2581_COMMAND exportPcbIpc2581Cmd
static CLI::SCH_EXPORT_PLOT_COMMAND exportSchDxfCmd
static CLI::JOBSET_COMMAND jobsetCmd
static CLI::SYM_EXPORT_COMMAND symExportCmd
static CLI::SYM_EXPORT_SVG_COMMAND symExportSvgCmd
static COMMAND_ENTRY * recurseArgParserSubCommandUsed(argparse::ArgumentParser &aArgParser, COMMAND_ENTRY &aEntry)
KIFACE_BASE & Kiface()
Global KIFACE_BASE "get" accessor.
static CLI::VERSION_COMMAND versionCmd
static CLI::PCB_EXPORT_3D_COMMAND exportPcbStlCmd
static CLI::PCB_EXPORT_PDF_COMMAND exportPcbPdfCmd
static CLI::PCB_EXPORT_3D_COMMAND exportPcbXaoCmd
static void recurseArgParserBuild(argparse::ArgumentParser &aArgParser, COMMAND_ENTRY &aEntry)
static CLI::SCH_EXPORT_NETLIST_COMMAND exportSchNetlistCmd
static CLI::SCH_EXPORT_PLOT_COMMAND exportSchPostscriptCmd
static CLI::PCB_EXPORT_GENCAD_COMMAND exportPcbGencadCmd
static CLI::FP_COMMAND fpCmd
static CLI::PCB_EXPORT_3D_COMMAND exportPcbGlbCmd
static CLI::SCH_EXPORT_COMMAND exportSchCmd
static CLI::PCB_EXPORT_3D_COMMAND exportPcbBrepCmd
#define KFCTL_CPP_PROJECT_SUITE
Running under C++ project mgr, possibly with others.
#define KFCTL_CLI
Running as CLI app.
static const int ERR_ARGS
static const int AVOID_CLOSING
void SetPgm(PGM_BASE *pgm)
PGM_BASE & Pgm()
The global Program "get" accessor.
KIWAY Kiway(KFCTL_STANDALONE)
std::vector< FAB_LAYER_COLOR > dummy
wxString From_UTF8(const char *cstring)
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.