diff --git a/kicad/cli/command.cpp b/kicad/cli/command.cpp index 04df671547..df790cfc2f 100644 --- a/kicad/cli/command.cpp +++ b/kicad/cli/command.cpp @@ -48,13 +48,23 @@ void CLI::COMMAND::PrintHelp() int CLI::COMMAND::Perform( KIWAY& aKiway ) { - if( m_argParser[ARG_HELP] == true ) + if( m_argParser[ ARG_HELP ] == true ) { PrintHelp(); return 0; } + if ( m_hasInputArg ) + { + m_argInput = FROM_UTF8( m_argParser.get( ARG_INPUT ).c_str() ); + } + + if( m_hasOutputArg ) + { + m_argOutput = FROM_UTF8( m_argParser.get( ARG_OUTPUT ).c_str() ); + } + return doPerform( aKiway ); } @@ -65,4 +75,33 @@ int CLI::COMMAND::doPerform( KIWAY& aKiway ) PrintHelp(); return EXIT_CODES::OK; +} + + +void CLI::COMMAND::addCommonArgs( bool aInput, bool aOutput, bool aOutputIsDir ) +{ + m_hasInputArg = aInput; + m_hasOutputArg = aOutput; + m_outputArgExpectsDir = aOutputIsDir; + + if( aInput ) + { + m_argParser.add_argument( ARG_INPUT ).help( UTF8STDSTR( _( "Input file" ) ) ); + } + + if( aOutput ) + { + if( aOutputIsDir ) + { + m_argParser.add_argument( "-o", ARG_OUTPUT ) + .default_value( std::string() ) + .help( UTF8STDSTR( _( "Output directory" ) ) ); + } + else + { + m_argParser.add_argument( "-o", ARG_OUTPUT ) + .default_value( std::string() ) + .help( UTF8STDSTR( _( "Output file name" ) ) ); + } + } } \ No newline at end of file diff --git a/kicad/cli/command.h b/kicad/cli/command.h index 7d7f3e1e26..9da3d4ee19 100644 --- a/kicad/cli/command.h +++ b/kicad/cli/command.h @@ -30,6 +30,8 @@ #define ARG_HELP "--help" #define ARG_HELP_SHORT "-h" #define ARG_HELP_DESC _( "shows help message and exits" ) +#define ARG_OUTPUT "--output" +#define ARG_INPUT "input" namespace CLI { @@ -55,7 +57,17 @@ public: const std::string& GetName() const { return m_name; } void PrintHelp(); + protected: + /** + * Sets up the most common of args used across cli + * + * @param aInput Configures the input arg + * @param aOutput Configures the output arg + * @param aOutputIsDir Configures whether the output arg description will be for a file or directory + */ + void addCommonArgs( bool aInput, bool aOutput, bool aOutputIsDir ); + /** * The internal handler that should be overloaded to implement command specific * processing and work. @@ -64,8 +76,37 @@ protected: */ virtual int doPerform( KIWAY& aKiway ); + /** + * Name of this command that is exported and used in the cli + */ std::string m_name; + argparse::ArgumentParser m_argParser; + + /** + * Whether or not the input arg was added for parsing + */ + bool m_hasInputArg; + + /** + * Whether or not the output arg was added for parsing + */ + bool m_hasOutputArg; + + /** + * Whether or not the output arg is expecting a directory + */ + bool m_outputArgExpectsDir; + + /** + * Value of the common input arg if configured + */ + wxString m_argInput; + + /** + * Value of the output arg if configured + */ + wxString m_argOutput; }; } diff --git a/kicad/cli/command_fp_export_svg.cpp b/kicad/cli/command_fp_export_svg.cpp index 77e1ee92a5..93130dbaa0 100644 --- a/kicad/cli/command_fp_export_svg.cpp +++ b/kicad/cli/command_fp_export_svg.cpp @@ -60,8 +60,8 @@ int CLI::FP_EXPORT_SVG_COMMAND::doPerform( KIWAY& aKiway ) std::unique_ptr svgJob = std::make_unique( true ); - svgJob->m_libraryPath = FROM_UTF8( m_argParser.get( ARG_INPUT ).c_str() ); - svgJob->m_outputDirectory = FROM_UTF8( m_argParser.get( ARG_OUTPUT ).c_str() ); + svgJob->m_libraryPath = m_argInput; + svgJob->m_outputDirectory = m_argOutput; svgJob->m_blackAndWhite = m_argParser.get( ARG_BLACKANDWHITE ); svgJob->m_footprint = FROM_UTF8( m_argParser.get( ARG_FOOTPRINT ).c_str() ); diff --git a/kicad/cli/command_fp_upgrade.cpp b/kicad/cli/command_fp_upgrade.cpp index 6b41b9537e..86159f93d1 100644 --- a/kicad/cli/command_fp_upgrade.cpp +++ b/kicad/cli/command_fp_upgrade.cpp @@ -46,8 +46,8 @@ int CLI::FP_UPGRADE_COMMAND::doPerform( KIWAY& aKiway ) { std::unique_ptr fpJob = std::make_unique( true ); - fpJob->m_libraryPath = FROM_UTF8( m_argParser.get( ARG_INPUT ).c_str() ); - fpJob->m_outputLibraryPath = FROM_UTF8( m_argParser.get( ARG_OUTPUT ).c_str() ); + fpJob->m_libraryPath = m_argInput; + fpJob->m_outputLibraryPath = m_argOutput; fpJob->m_force = m_argParser.get( ARG_FORCE ); if( !wxDir::Exists( fpJob->m_libraryPath ) ) diff --git a/kicad/cli/command_pcb_drc.cpp b/kicad/cli/command_pcb_drc.cpp index d34453569a..ea96313ca0 100644 --- a/kicad/cli/command_pcb_drc.cpp +++ b/kicad/cli/command_pcb_drc.cpp @@ -37,8 +37,10 @@ #define ARG_SEVERITY_EXCLUSIONS "--severity-exclusions" #define ARG_EXIT_CODE_VIOLATIONS "--exit-code-violations" -CLI::PCB_DRC_COMMAND::PCB_DRC_COMMAND() : PCB_EXPORT_BASE_COMMAND( "drc" ) +CLI::PCB_DRC_COMMAND::PCB_DRC_COMMAND() : COMMAND( "drc" ) { + addCommonArgs( true, true, false ); + m_argParser.add_description( UTF8STDSTR( _( "Runs the Design Rules Check (DRC) on the PCB and creates a report" ) ) ); m_argParser.add_argument( ARG_FORMAT ) @@ -90,8 +92,8 @@ int CLI::PCB_DRC_COMMAND::doPerform( KIWAY& aKiway ) { std::unique_ptr drcJob( new JOB_PCB_DRC( true ) ); - drcJob->m_outputFile = FROM_UTF8( m_argParser.get( ARG_OUTPUT ).c_str() ); - drcJob->m_filename = FROM_UTF8( m_argParser.get( ARG_INPUT ).c_str() ); + drcJob->m_outputFile = m_argOutput; + drcJob->m_filename = m_argInput; drcJob->m_reportAllTrackErrors = m_argParser.get( ARG_ALL_TRACK_ERRORS ); drcJob->m_exitCodeViolations = m_argParser.get( ARG_EXIT_CODE_VIOLATIONS ); diff --git a/kicad/cli/command_pcb_drc.h b/kicad/cli/command_pcb_drc.h index 86e197b0aa..3713c02e22 100644 --- a/kicad/cli/command_pcb_drc.h +++ b/kicad/cli/command_pcb_drc.h @@ -25,7 +25,7 @@ namespace CLI { -class PCB_DRC_COMMAND : public PCB_EXPORT_BASE_COMMAND +class PCB_DRC_COMMAND : public COMMAND { public: PCB_DRC_COMMAND(); diff --git a/kicad/cli/command_pcb_export_3d.cpp b/kicad/cli/command_pcb_export_3d.cpp index b91d81b676..378e6a8ff6 100644 --- a/kicad/cli/command_pcb_export_3d.cpp +++ b/kicad/cli/command_pcb_export_3d.cpp @@ -164,8 +164,8 @@ int CLI::PCB_EXPORT_3D_COMMAND::doPerform( KIWAY& aKiway ) } step->m_overwrite = m_argParser.get( ARG_FORCE ); - step->m_filename = FROM_UTF8( m_argParser.get( ARG_INPUT ).c_str() ); - step->m_outputFile = FROM_UTF8( m_argParser.get( ARG_OUTPUT ).c_str() ); + step->m_filename = m_argInput; + step->m_outputFile = m_argOutput; step->m_format = m_format; if( step->m_format == JOB_EXPORT_PCB_3D::FORMAT::UNKNOWN ) diff --git a/kicad/cli/command_pcb_export_base.cpp b/kicad/cli/command_pcb_export_base.cpp index 097f806526..40c9262d23 100644 --- a/kicad/cli/command_pcb_export_base.cpp +++ b/kicad/cli/command_pcb_export_base.cpp @@ -36,20 +36,7 @@ CLI::PCB_EXPORT_BASE_COMMAND::PCB_EXPORT_BASE_COMMAND( const std::string& aName, m_requireLayers = false; m_hasLayerArg = false; - if( aOutputIsDir ) - { - m_argParser.add_argument( "-o", ARG_OUTPUT ) - .default_value( std::string() ) - .help( UTF8STDSTR( _( "Output directory:" ) ) ); // todo fix after string freeze in v8 - } - else - { - m_argParser.add_argument( "-o", ARG_OUTPUT ) - .default_value( std::string() ) - .help( UTF8STDSTR( _( "Output file name" ) ) ); - } - - m_argParser.add_argument( ARG_INPUT ).help( UTF8STDSTR( _( "Input file" ) ) ); + addCommonArgs( true, true, aOutputIsDir ); // Build list of layer names and their layer mask: for( int layer = 0; layer < PCB_LAYER_ID_COUNT; ++layer ) diff --git a/kicad/cli/command_pcb_export_base.h b/kicad/cli/command_pcb_export_base.h index 24016273a7..8b2a40094c 100644 --- a/kicad/cli/command_pcb_export_base.h +++ b/kicad/cli/command_pcb_export_base.h @@ -26,9 +26,6 @@ namespace CLI { -#define ARG_OUTPUT "--output" -#define ARG_INPUT "input" - #define ARG_BLACKANDWHITE "--black-and-white" #define ARG_BLACKANDWHITE_DESC "Black and white only" diff --git a/kicad/cli/command_pcb_export_drill.cpp b/kicad/cli/command_pcb_export_drill.cpp index f86b243005..a036b70d69 100644 --- a/kicad/cli/command_pcb_export_drill.cpp +++ b/kicad/cli/command_pcb_export_drill.cpp @@ -97,8 +97,8 @@ int CLI::PCB_EXPORT_DRILL_COMMAND::doPerform( KIWAY& aKiway ) { std::unique_ptr drillJob( new JOB_EXPORT_PCB_DRILL( true ) ); - drillJob->m_filename = FROM_UTF8( m_argParser.get( ARG_INPUT ).c_str() ); - drillJob->m_outputDir = FROM_UTF8( m_argParser.get( ARG_OUTPUT ).c_str() ); + drillJob->m_filename = m_argInput; + drillJob->m_outputDir = m_argOutput; if( !drillJob->m_outputDir.IsEmpty() ) { diff --git a/kicad/cli/command_pcb_export_dxf.cpp b/kicad/cli/command_pcb_export_dxf.cpp index ee11f36de5..98acd64047 100644 --- a/kicad/cli/command_pcb_export_dxf.cpp +++ b/kicad/cli/command_pcb_export_dxf.cpp @@ -66,8 +66,8 @@ int CLI::PCB_EXPORT_DXF_COMMAND::doPerform( KIWAY& aKiway ) std::unique_ptr dxfJob( new JOB_EXPORT_PCB_DXF( true ) ); - dxfJob->m_filename = FROM_UTF8( m_argParser.get( ARG_INPUT ).c_str() ); - dxfJob->m_outputFile = FROM_UTF8( m_argParser.get( ARG_OUTPUT ).c_str() ); + dxfJob->m_filename = m_argInput; + dxfJob->m_outputFile = m_argOutput; if( !wxFile::Exists( dxfJob->m_filename ) ) { diff --git a/kicad/cli/command_pcb_export_gerber.cpp b/kicad/cli/command_pcb_export_gerber.cpp index bbd6309e42..9d46d53fb9 100644 --- a/kicad/cli/command_pcb_export_gerber.cpp +++ b/kicad/cli/command_pcb_export_gerber.cpp @@ -97,8 +97,8 @@ CLI::PCB_EXPORT_GERBER_COMMAND::PCB_EXPORT_GERBER_COMMAND() : PCB_EXPORT_GERBER_ int CLI::PCB_EXPORT_GERBER_COMMAND::populateJob( JOB_EXPORT_PCB_GERBER* aJob ) { - aJob->m_filename = FROM_UTF8( m_argParser.get( ARG_INPUT ).c_str() ); - aJob->m_outputFile = FROM_UTF8( m_argParser.get( ARG_OUTPUT ).c_str() ); + aJob->m_filename = m_argInput; + aJob->m_outputFile = m_argOutput; aJob->m_plotFootprintValues = !m_argParser.get( ARG_EXCLUDE_VALUE ); aJob->m_plotRefDes = !m_argParser.get( ARG_EXCLUDE_REFDES ); diff --git a/kicad/cli/command_pcb_export_pdf.cpp b/kicad/cli/command_pcb_export_pdf.cpp index d5ba664b27..2c0b45e381 100644 --- a/kicad/cli/command_pcb_export_pdf.cpp +++ b/kicad/cli/command_pcb_export_pdf.cpp @@ -88,8 +88,8 @@ int CLI::PCB_EXPORT_PDF_COMMAND::doPerform( KIWAY& aKiway ) std::unique_ptr pdfJob( new JOB_EXPORT_PCB_PDF( true ) ); - pdfJob->m_filename = FROM_UTF8( m_argParser.get( ARG_INPUT ).c_str() ); - pdfJob->m_outputFile = FROM_UTF8( m_argParser.get( ARG_OUTPUT ).c_str() ); + pdfJob->m_filename = m_argInput; + pdfJob->m_outputFile = m_argOutput; if( !wxFile::Exists( pdfJob->m_filename ) ) { diff --git a/kicad/cli/command_pcb_export_pos.cpp b/kicad/cli/command_pcb_export_pos.cpp index abecd0502b..c297866610 100644 --- a/kicad/cli/command_pcb_export_pos.cpp +++ b/kicad/cli/command_pcb_export_pos.cpp @@ -100,8 +100,8 @@ int CLI::PCB_EXPORT_POS_COMMAND::doPerform( KIWAY& aKiway ) std::unique_ptr aPosJob( new JOB_EXPORT_PCB_POS( true ) ); - aPosJob->m_filename = FROM_UTF8( m_argParser.get( ARG_INPUT ).c_str() ); - aPosJob->m_outputFile = FROM_UTF8( m_argParser.get( ARG_OUTPUT ).c_str() ); + aPosJob->m_filename = m_argInput; + aPosJob->m_outputFile = m_argOutput; if( !wxFile::Exists( aPosJob->m_filename ) ) { diff --git a/kicad/cli/command_pcb_export_svg.cpp b/kicad/cli/command_pcb_export_svg.cpp index fbb13a7bad..fb03a5100b 100644 --- a/kicad/cli/command_pcb_export_svg.cpp +++ b/kicad/cli/command_pcb_export_svg.cpp @@ -92,8 +92,8 @@ int CLI::PCB_EXPORT_SVG_COMMAND::doPerform( KIWAY& aKiway ) svgJob->m_negative = m_argParser.get( ARG_NEGATIVE ); svgJob->m_drillShapeOption = m_argParser.get( ARG_DRILL_SHAPE_OPTION ); - svgJob->m_filename = FROM_UTF8( m_argParser.get( ARG_INPUT ).c_str() ); - svgJob->m_outputFile = FROM_UTF8( m_argParser.get( ARG_OUTPUT ).c_str() ); + svgJob->m_filename = m_argInput; + svgJob->m_outputFile = m_argOutput; svgJob->m_colorTheme = FROM_UTF8( m_argParser.get( ARG_THEME ).c_str() ); svgJob->m_plotDrawingSheet = !m_argParser.get( ARG_EXCLUDE_DRAWING_SHEET ); diff --git a/kicad/cli/command_sch_erc.cpp b/kicad/cli/command_sch_erc.cpp index 6aace29d60..18c1faad90 100644 --- a/kicad/cli/command_sch_erc.cpp +++ b/kicad/cli/command_sch_erc.cpp @@ -36,8 +36,10 @@ #define ARG_SEVERITY_EXCLUSIONS "--severity-exclusions" #define ARG_EXIT_CODE_VIOLATIONS "--exit-code-violations" -CLI::SCH_ERC_COMMAND::SCH_ERC_COMMAND() : PCB_EXPORT_BASE_COMMAND( "erc" ) +CLI::SCH_ERC_COMMAND::SCH_ERC_COMMAND() : COMMAND( "erc" ) { + addCommonArgs( true, true, false ); + m_argParser.add_description( UTF8STDSTR( _( "Runs the Electrical Rules Check (ERC) on the schematic and creates a report" ) ) ); m_argParser.add_argument( ARG_FORMAT ) @@ -84,8 +86,8 @@ int CLI::SCH_ERC_COMMAND::doPerform( KIWAY& aKiway ) { std::unique_ptr ercJob( new JOB_SCH_ERC( true ) ); - ercJob->m_outputFile = FROM_UTF8( m_argParser.get( ARG_OUTPUT ).c_str() ); - ercJob->m_filename = FROM_UTF8( m_argParser.get( ARG_INPUT ).c_str() ); + ercJob->m_outputFile = m_argOutput; + ercJob->m_filename = m_argInput; ercJob->m_exitCodeViolations = m_argParser.get( ARG_EXIT_CODE_VIOLATIONS ); if( m_argParser.get( ARG_SEVERITY_ALL ) ) diff --git a/kicad/cli/command_sch_erc.h b/kicad/cli/command_sch_erc.h index 78ac6a6d9d..83eb4808df 100644 --- a/kicad/cli/command_sch_erc.h +++ b/kicad/cli/command_sch_erc.h @@ -25,7 +25,7 @@ namespace CLI { -class SCH_ERC_COMMAND : public PCB_EXPORT_BASE_COMMAND +class SCH_ERC_COMMAND : public COMMAND { public: SCH_ERC_COMMAND(); diff --git a/kicad/cli/command_sch_export_bom.cpp b/kicad/cli/command_sch_export_bom.cpp index c4d6be51bf..f93401ae95 100644 --- a/kicad/cli/command_sch_export_bom.cpp +++ b/kicad/cli/command_sch_export_bom.cpp @@ -29,8 +29,10 @@ #include -CLI::SCH_EXPORT_BOM_COMMAND::SCH_EXPORT_BOM_COMMAND() : PCB_EXPORT_BASE_COMMAND( "bom" ) +CLI::SCH_EXPORT_BOM_COMMAND::SCH_EXPORT_BOM_COMMAND() : COMMAND( "bom" ) { + addCommonArgs( true, true, false ); + // Field output options m_argParser.add_argument( ARG_FIELDS ) .help( UTF8STDSTR( _( ARG_FIELDS_DESC ) ) ) @@ -111,8 +113,8 @@ int CLI::SCH_EXPORT_BOM_COMMAND::doPerform( KIWAY& aKiway ) std::unique_ptr bomJob = std::make_unique( true ); // Basic options - bomJob->m_filename = FROM_UTF8( m_argParser.get( ARG_INPUT ).c_str() ); - bomJob->m_outputFile = FROM_UTF8( m_argParser.get( ARG_OUTPUT ).c_str() ); + bomJob->m_filename = m_argInput; + bomJob->m_outputFile = m_argOutput; // Format options bomJob->m_fieldDelimiter = diff --git a/kicad/cli/command_sch_export_bom.h b/kicad/cli/command_sch_export_bom.h index 343bcc35db..906ed30e75 100644 --- a/kicad/cli/command_sch_export_bom.h +++ b/kicad/cli/command_sch_export_bom.h @@ -67,7 +67,7 @@ namespace CLI #define ARG_EXCLUDE_DNP "--exclude-dnp" #define ARG_EXCLUDE_DNP_DESC "Exclude symbols marked Do-Not-Populate." -class SCH_EXPORT_BOM_COMMAND : public PCB_EXPORT_BASE_COMMAND +class SCH_EXPORT_BOM_COMMAND : public COMMAND { public: SCH_EXPORT_BOM_COMMAND(); diff --git a/kicad/cli/command_sch_export_netlist.cpp b/kicad/cli/command_sch_export_netlist.cpp index b84c7f5bcb..93ea702a47 100644 --- a/kicad/cli/command_sch_export_netlist.cpp +++ b/kicad/cli/command_sch_export_netlist.cpp @@ -29,8 +29,10 @@ #define ARG_FORMAT "--format" -CLI::SCH_EXPORT_NETLIST_COMMAND::SCH_EXPORT_NETLIST_COMMAND() : PCB_EXPORT_BASE_COMMAND( "netlist" ) +CLI::SCH_EXPORT_NETLIST_COMMAND::SCH_EXPORT_NETLIST_COMMAND() : COMMAND( "netlist" ) { + addCommonArgs( true, true, false ); + m_argParser.add_argument( ARG_FORMAT ) .default_value( std::string( "kicadsexpr" ) ) .help( UTF8STDSTR( _( "Netlist output format, valid options: kicadsexpr, kicadxml, cadstar, orcadpcb2, spice, spicemodel" ) ) ); @@ -42,8 +44,8 @@ int CLI::SCH_EXPORT_NETLIST_COMMAND::doPerform( KIWAY& aKiway ) std::unique_ptr netJob = std::make_unique( true ); - netJob->m_filename = FROM_UTF8( m_argParser.get( ARG_INPUT ).c_str() ); - netJob->m_outputFile = FROM_UTF8( m_argParser.get( ARG_OUTPUT ).c_str() ); + netJob->m_filename = m_argInput; + netJob->m_outputFile = m_argOutput; if( !wxFile::Exists( netJob->m_filename ) ) { diff --git a/kicad/cli/command_sch_export_netlist.h b/kicad/cli/command_sch_export_netlist.h index c4c89b3fd8..78f76d443a 100644 --- a/kicad/cli/command_sch_export_netlist.h +++ b/kicad/cli/command_sch_export_netlist.h @@ -25,7 +25,7 @@ namespace CLI { -class SCH_EXPORT_NETLIST_COMMAND : public PCB_EXPORT_BASE_COMMAND +class SCH_EXPORT_NETLIST_COMMAND : public COMMAND { public: SCH_EXPORT_NETLIST_COMMAND(); diff --git a/kicad/cli/command_sch_export_plot.cpp b/kicad/cli/command_sch_export_plot.cpp index 22fa7fdfb4..e3865dc87d 100644 --- a/kicad/cli/command_sch_export_plot.cpp +++ b/kicad/cli/command_sch_export_plot.cpp @@ -43,9 +43,11 @@ const HPGL_PLOT_ORIGIN_AND_UNITS hpgl_origin_ops[4] = { CLI::SCH_EXPORT_PLOT_COMMAND::SCH_EXPORT_PLOT_COMMAND( const std::string& aName, PLOT_FORMAT aPlotFormat, bool aOutputIsDir ) : - PCB_EXPORT_BASE_COMMAND( aName, aOutputIsDir ), - m_plotFormat( aPlotFormat ), m_useDir( aOutputIsDir ) + COMMAND( aName ), + m_plotFormat( aPlotFormat ) { + addCommonArgs( true, true, aOutputIsDir ); + m_argParser.add_argument( "-t", ARG_THEME ) .default_value( std::string() ) .help( UTF8STDSTR( _( "Color theme to use (will default to schematic settings)" ) ) ); @@ -88,7 +90,7 @@ CLI::SCH_EXPORT_PLOT_COMMAND::SCH_EXPORT_PLOT_COMMAND( const std::string& aName, int CLI::SCH_EXPORT_PLOT_COMMAND::doPerform( KIWAY& aKiway ) { - wxString filename = FROM_UTF8( m_argParser.get( ARG_INPUT ).c_str() ); + wxString filename = m_argInput; if( !wxFile::Exists( filename ) ) { wxFprintf( stderr, _( "Schematic file does not exist or is not accessible\n" ) ); @@ -105,11 +107,10 @@ int CLI::SCH_EXPORT_PLOT_COMMAND::doPerform( KIWAY& aKiway ) settings.m_pageSizeSelect = PAGE_SIZE_AUTO; settings.m_useBackgroundColor = !m_argParser.get( ARG_NO_BACKGROUND_COLOR ); settings.m_theme = FROM_UTF8( m_argParser.get( ARG_THEME ).c_str() ); - if( m_useDir ) - settings.m_outputDirectory = - FROM_UTF8( m_argParser.get( ARG_OUTPUT ).c_str() ); + if( m_outputArgExpectsDir ) + settings.m_outputDirectory = m_argOutput; else - settings.m_outputFile = FROM_UTF8( m_argParser.get( ARG_OUTPUT ).c_str() ); + settings.m_outputFile = m_argOutput; // HPGL local options if( m_plotFormat == PLOT_FORMAT::HPGL ) { diff --git a/kicad/cli/command_sch_export_plot.h b/kicad/cli/command_sch_export_plot.h index 9ec29c922b..35f04cee93 100644 --- a/kicad/cli/command_sch_export_plot.h +++ b/kicad/cli/command_sch_export_plot.h @@ -26,14 +26,13 @@ namespace CLI { -class SCH_EXPORT_PLOT_COMMAND : public PCB_EXPORT_BASE_COMMAND +class SCH_EXPORT_PLOT_COMMAND : public COMMAND { public: SCH_EXPORT_PLOT_COMMAND( const std::string& aName, PLOT_FORMAT aPlotFormat, bool aOutputIsDir = true ); PLOT_FORMAT m_plotFormat; - bool m_useDir; protected: int doPerform( KIWAY& aKiway ) override; diff --git a/kicad/cli/command_sch_export_pythonbom.cpp b/kicad/cli/command_sch_export_pythonbom.cpp index aad5cfea25..7864a85031 100644 --- a/kicad/cli/command_sch_export_pythonbom.cpp +++ b/kicad/cli/command_sch_export_pythonbom.cpp @@ -29,8 +29,10 @@ CLI::SCH_EXPORT_PYTHONBOM_COMMAND::SCH_EXPORT_PYTHONBOM_COMMAND() : - PCB_EXPORT_BASE_COMMAND( "python-bom" ) -{ + COMMAND( "python-bom" ) +{ + addCommonArgs( true, true, false ); + m_argParser.add_description( UTF8STDSTR( _( "Export the legacy bom xml format used in the " "schematic editor with python scripts" ) ) ); } @@ -41,8 +43,8 @@ int CLI::SCH_EXPORT_PYTHONBOM_COMMAND::doPerform( KIWAY& aKiway ) std::unique_ptr bomJob = std::make_unique( true ); - bomJob->m_filename = FROM_UTF8( m_argParser.get( ARG_INPUT ).c_str() ); - bomJob->m_outputFile = FROM_UTF8( m_argParser.get( ARG_OUTPUT ).c_str() ); + bomJob->m_filename = m_argInput; + bomJob->m_outputFile = m_argOutput; if( !wxFile::Exists( bomJob->m_filename ) ) { diff --git a/kicad/cli/command_sch_export_pythonbom.h b/kicad/cli/command_sch_export_pythonbom.h index 0f271517d6..60b8f84308 100644 --- a/kicad/cli/command_sch_export_pythonbom.h +++ b/kicad/cli/command_sch_export_pythonbom.h @@ -25,7 +25,7 @@ namespace CLI { -class SCH_EXPORT_PYTHONBOM_COMMAND : public PCB_EXPORT_BASE_COMMAND +class SCH_EXPORT_PYTHONBOM_COMMAND : public COMMAND { public: SCH_EXPORT_PYTHONBOM_COMMAND(); diff --git a/kicad/cli/command_sym_export_svg.cpp b/kicad/cli/command_sym_export_svg.cpp index e47a17cf7c..1818aceb86 100644 --- a/kicad/cli/command_sym_export_svg.cpp +++ b/kicad/cli/command_sym_export_svg.cpp @@ -33,8 +33,10 @@ #define ARG_INC_HIDDEN_PINS "--include-hidden-pins" #define ARG_INC_HIDDEN_FIELDS "--include-hidden-fields" -CLI::SYM_EXPORT_SVG_COMMAND::SYM_EXPORT_SVG_COMMAND() : PCB_EXPORT_BASE_COMMAND( "svg" ) +CLI::SYM_EXPORT_SVG_COMMAND::SYM_EXPORT_SVG_COMMAND() : COMMAND( "svg" ) { + addCommonArgs( true, true, false ); + m_argParser.add_description( UTF8STDSTR( _( "Exports the symbol or entire symbol library to SVG" ) ) ); m_argParser.add_argument( "-t", ARG_THEME ) @@ -66,8 +68,8 @@ int CLI::SYM_EXPORT_SVG_COMMAND::doPerform( KIWAY& aKiway ) { std::unique_ptr svgJob = std::make_unique( true ); - svgJob->m_libraryPath = FROM_UTF8( m_argParser.get( ARG_INPUT ).c_str() ); - svgJob->m_outputDirectory = FROM_UTF8( m_argParser.get( ARG_OUTPUT ).c_str() ); + svgJob->m_libraryPath = m_argInput; + svgJob->m_outputDirectory = m_argOutput; svgJob->m_blackAndWhite = m_argParser.get( ARG_BLACKANDWHITE ); svgJob->m_symbol = FROM_UTF8( m_argParser.get( ARG_SYMBOL ).c_str() ); svgJob->m_includeHiddenFields = m_argParser.get( ARG_INC_HIDDEN_FIELDS ); diff --git a/kicad/cli/command_sym_export_svg.h b/kicad/cli/command_sym_export_svg.h index 5f673a7c1a..d04e3fb404 100644 --- a/kicad/cli/command_sym_export_svg.h +++ b/kicad/cli/command_sym_export_svg.h @@ -25,7 +25,7 @@ namespace CLI { -class SYM_EXPORT_SVG_COMMAND : public PCB_EXPORT_BASE_COMMAND +class SYM_EXPORT_SVG_COMMAND : public COMMAND { public: SYM_EXPORT_SVG_COMMAND(); diff --git a/kicad/cli/command_sym_upgrade.cpp b/kicad/cli/command_sym_upgrade.cpp index 55c32a3b69..25a0c725f5 100644 --- a/kicad/cli/command_sym_upgrade.cpp +++ b/kicad/cli/command_sym_upgrade.cpp @@ -30,8 +30,10 @@ #define ARG_FORCE "--force" -CLI::SYM_UPGRADE_COMMAND::SYM_UPGRADE_COMMAND() : PCB_EXPORT_BASE_COMMAND( "upgrade" ) +CLI::SYM_UPGRADE_COMMAND::SYM_UPGRADE_COMMAND() : COMMAND( "upgrade" ) { + addCommonArgs( true, true, false ); + m_argParser.add_description( UTF8STDSTR( _( "Upgrades the symbol library to the current kicad version format" ) ) ); m_argParser.add_argument( ARG_FORCE ) @@ -46,8 +48,8 @@ int CLI::SYM_UPGRADE_COMMAND::doPerform( KIWAY& aKiway ) { std::unique_ptr symJob = std::make_unique( true ); - symJob->m_libraryPath = FROM_UTF8( m_argParser.get( ARG_INPUT ).c_str() ); - symJob->m_outputLibraryPath = FROM_UTF8( m_argParser.get( ARG_OUTPUT ).c_str() ); + symJob->m_libraryPath = m_argInput; + symJob->m_outputLibraryPath = m_argOutput; symJob->m_force = m_argParser.get( ARG_FORCE ); if( !wxFile::Exists( symJob->m_libraryPath ) ) diff --git a/kicad/cli/command_sym_upgrade.h b/kicad/cli/command_sym_upgrade.h index 46413ae5f9..c17777dbc4 100644 --- a/kicad/cli/command_sym_upgrade.h +++ b/kicad/cli/command_sym_upgrade.h @@ -25,7 +25,7 @@ namespace CLI { -class SYM_UPGRADE_COMMAND : public PCB_EXPORT_BASE_COMMAND +class SYM_UPGRADE_COMMAND : public COMMAND { public: SYM_UPGRADE_COMMAND();