diff --git a/kicad/cli/command.cpp b/kicad/cli/command.cpp index b6fa49b512..bd726cd750 100644 --- a/kicad/cli/command.cpp +++ b/kicad/cli/command.cpp @@ -112,7 +112,7 @@ int CLI::COMMAND::doPerform( KIWAY& aKiway ) } -void CLI::COMMAND::addCommonArgs( bool aInput, bool aOutput, bool aOutputIsDir ) +void CLI::COMMAND::addCommonArgs( bool aInput, bool aOutput, bool aInputIsDir, bool aOutputIsDir ) { m_hasInputArg = aInput; m_hasOutputArg = aOutput; @@ -120,9 +120,18 @@ void CLI::COMMAND::addCommonArgs( bool aInput, bool aOutput, bool aOutputIsDir ) if( aInput ) { - m_argParser.add_argument( ARG_INPUT ) - .help( UTF8STDSTR( _( "Input file" ) ) ) - .metavar( "INPUT_FILE" ); + if( aInputIsDir ) + { + m_argParser.add_argument( ARG_INPUT ) + .help( UTF8STDSTR( _( "Input directory" ) ) ) + .metavar( "INPUT_DIR" ); + } + else + { + m_argParser.add_argument( ARG_INPUT ) + .help( UTF8STDSTR( _( "Input file" ) ) ) + .metavar( "INPUT_FILE" ); + } } if( aOutput ) @@ -138,7 +147,7 @@ void CLI::COMMAND::addCommonArgs( bool aInput, bool aOutput, bool aOutputIsDir ) { m_argParser.add_argument( "-o", ARG_OUTPUT ) .default_value( std::string() ) - .help( UTF8STDSTR( _( "Output file name" ) ) ) + .help( UTF8STDSTR( _( "Output file" ) ) ) .metavar( "OUTPUT_FILE" ); } } @@ -166,4 +175,4 @@ void CLI::COMMAND::addDefineArg() _( "Overrides or adds project variables, can be used multiple times to declare multiple variables." "\nUse in the format of '--define-var key=value' or '-D key=value'" ) ) ) .metavar( "KEY=VALUE" ); -} \ No newline at end of file +} diff --git a/kicad/cli/command.h b/kicad/cli/command.h index 386134e486..18bd6b5669 100644 --- a/kicad/cli/command.h +++ b/kicad/cli/command.h @@ -67,9 +67,10 @@ protected: * * @param aInput Configures the input arg * @param aOutput Configures the output arg + * @param aInputIsDir Configures whether the input arg description will be for a file or directory * @param aOutputIsDir Configures whether the output arg description will be for a file or directory */ - void addCommonArgs( bool aInput, bool aOutput, bool aOutputIsDir ); + void addCommonArgs( bool aInput, bool aOutput, bool aInputIsDir, bool aOutputIsDir ); /** * Sets up the drawing sheet arg used by many of the export commands diff --git a/kicad/cli/command_fp_export_svg.cpp b/kicad/cli/command_fp_export_svg.cpp index 40301133d1..975cff74ab 100644 --- a/kicad/cli/command_fp_export_svg.cpp +++ b/kicad/cli/command_fp_export_svg.cpp @@ -32,7 +32,7 @@ #define ARG_FOOTPRINT "--footprint" -CLI::FP_EXPORT_SVG_COMMAND::FP_EXPORT_SVG_COMMAND() : PCB_EXPORT_BASE_COMMAND( "svg" ) +CLI::FP_EXPORT_SVG_COMMAND::FP_EXPORT_SVG_COMMAND() : PCB_EXPORT_BASE_COMMAND( "svg", true ) { m_argParser.add_description( UTF8STDSTR( _( "Exports the footprint or entire footprint library to SVG" ) ) ); diff --git a/kicad/cli/command_fp_upgrade.cpp b/kicad/cli/command_fp_upgrade.cpp index 86159f93d1..3df0115c50 100644 --- a/kicad/cli/command_fp_upgrade.cpp +++ b/kicad/cli/command_fp_upgrade.cpp @@ -30,7 +30,7 @@ #define ARG_FORCE "--force" -CLI::FP_UPGRADE_COMMAND::FP_UPGRADE_COMMAND() : PCB_EXPORT_BASE_COMMAND( "upgrade" ) +CLI::FP_UPGRADE_COMMAND::FP_UPGRADE_COMMAND() : PCB_EXPORT_BASE_COMMAND( "upgrade", true, true ) { m_argParser.add_description( UTF8STDSTR( _( "Upgrades the footprint library to the current kicad version format" ) ) ); diff --git a/kicad/cli/command_pcb_drc.cpp b/kicad/cli/command_pcb_drc.cpp index 4a84d7f6df..87f0363094 100644 --- a/kicad/cli/command_pcb_drc.cpp +++ b/kicad/cli/command_pcb_drc.cpp @@ -40,7 +40,7 @@ CLI::PCB_DRC_COMMAND::PCB_DRC_COMMAND() : COMMAND( "drc" ) { - addCommonArgs( true, true, false ); + addCommonArgs( true, true, false, false ); addDefineArg(); m_argParser.add_description( UTF8STDSTR( _( "Runs the Design Rules Check (DRC) on the PCB and creates a report" ) ) ); diff --git a/kicad/cli/command_pcb_export_3d.cpp b/kicad/cli/command_pcb_export_3d.cpp index d4ce0c590c..950869982c 100644 --- a/kicad/cli/command_pcb_export_3d.cpp +++ b/kicad/cli/command_pcb_export_3d.cpp @@ -55,7 +55,7 @@ CLI::PCB_EXPORT_3D_COMMAND::PCB_EXPORT_3D_COMMAND( const std::string& aNa m_format( aFormat ) { m_argParser.add_description( aDescription ); - addCommonArgs( true, true, false ); + addCommonArgs( true, true, false, false ); addDefineArg(); if( 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 7bf4266a3e..788753c0bd 100644 --- a/kicad/cli/command_pcb_export_base.cpp +++ b/kicad/cli/command_pcb_export_base.cpp @@ -30,6 +30,7 @@ #include CLI::PCB_EXPORT_BASE_COMMAND::PCB_EXPORT_BASE_COMMAND( const std::string& aName, + bool aInputIsDir, bool aOutputIsDir ) : COMMAND( aName ) { @@ -37,7 +38,7 @@ CLI::PCB_EXPORT_BASE_COMMAND::PCB_EXPORT_BASE_COMMAND( const std::string& aName, m_requireLayers = false; m_hasLayerArg = false; - addCommonArgs( true, true, aOutputIsDir ); + addCommonArgs( true, true, aInputIsDir, 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 8b2a40094c..6f71dd11f9 100644 --- a/kicad/cli/command_pcb_export_base.h +++ b/kicad/cli/command_pcb_export_base.h @@ -42,7 +42,7 @@ namespace CLI struct PCB_EXPORT_BASE_COMMAND : public COMMAND { - PCB_EXPORT_BASE_COMMAND( const std::string& aName, bool aOutputIsDir = false ); + PCB_EXPORT_BASE_COMMAND( const std::string& aName, bool aInputIsDir = false, bool aOutputIsDir = false ); protected: int doPerform( KIWAY& aKiway ) override; diff --git a/kicad/cli/command_pcb_export_drill.cpp b/kicad/cli/command_pcb_export_drill.cpp index 280bea7840..93ad97e53b 100644 --- a/kicad/cli/command_pcb_export_drill.cpp +++ b/kicad/cli/command_pcb_export_drill.cpp @@ -41,7 +41,7 @@ #define ARG_MAP_FORMAT "--map-format" #define ARG_DRILL_ORIGIN "--drill-origin" -CLI::PCB_EXPORT_DRILL_COMMAND::PCB_EXPORT_DRILL_COMMAND() : PCB_EXPORT_BASE_COMMAND( "drill" ) +CLI::PCB_EXPORT_DRILL_COMMAND::PCB_EXPORT_DRILL_COMMAND() : PCB_EXPORT_BASE_COMMAND( "drill", false, true ) { m_argParser.add_description( UTF8STDSTR( _( "Generate Drill Files" ) ) ); diff --git a/kicad/cli/command_sch_erc.cpp b/kicad/cli/command_sch_erc.cpp index 320bb1f726..0aa2886a0c 100644 --- a/kicad/cli/command_sch_erc.cpp +++ b/kicad/cli/command_sch_erc.cpp @@ -39,7 +39,7 @@ CLI::SCH_ERC_COMMAND::SCH_ERC_COMMAND() : COMMAND( "erc" ) { - addCommonArgs( true, true, false ); + addCommonArgs( true, true, false, false ); addDefineArg(); m_argParser.add_description( UTF8STDSTR( _( "Runs the Electrical Rules Check (ERC) on the schematic and creates a report" ) ) ); diff --git a/kicad/cli/command_sch_export_bom.cpp b/kicad/cli/command_sch_export_bom.cpp index 1dd3c16f99..e20d297682 100644 --- a/kicad/cli/command_sch_export_bom.cpp +++ b/kicad/cli/command_sch_export_bom.cpp @@ -33,7 +33,7 @@ CLI::SCH_EXPORT_BOM_COMMAND::SCH_EXPORT_BOM_COMMAND() : COMMAND( "bom" ) { m_argParser.add_description( UTF8STDSTR( _( "Generate a Bill of Material (BOM)" ) ) ); - addCommonArgs( true, true, false ); + addCommonArgs( true, true, false, false ); // Field output options m_argParser.add_argument( ARG_FIELDS ) diff --git a/kicad/cli/command_sch_export_netlist.cpp b/kicad/cli/command_sch_export_netlist.cpp index fe03540ab2..c42eb50a1d 100644 --- a/kicad/cli/command_sch_export_netlist.cpp +++ b/kicad/cli/command_sch_export_netlist.cpp @@ -33,7 +33,7 @@ CLI::SCH_EXPORT_NETLIST_COMMAND::SCH_EXPORT_NETLIST_COMMAND() : COMMAND( "netlist" ) { m_argParser.add_description( UTF8STDSTR( _( "Export a Netlist" ) ) ); - addCommonArgs( true, true, false ); + addCommonArgs( true, true, false, false ); m_argParser.add_argument( ARG_FORMAT ) .default_value( std::string( "kicadsexpr" ) ) @@ -91,4 +91,4 @@ int CLI::SCH_EXPORT_NETLIST_COMMAND::doPerform( KIWAY& aKiway ) int exitCode = aKiway.ProcessJob( KIWAY::FACE_SCH, netJob.get() ); return exitCode; -} \ No newline at end of file +} diff --git a/kicad/cli/command_sch_export_plot.cpp b/kicad/cli/command_sch_export_plot.cpp index ba266a20bb..7ce818dfeb 100644 --- a/kicad/cli/command_sch_export_plot.cpp +++ b/kicad/cli/command_sch_export_plot.cpp @@ -50,7 +50,7 @@ CLI::SCH_EXPORT_PLOT_COMMAND::SCH_EXPORT_PLOT_COMMAND( const std::string& aName, { m_argParser.add_description( aDescription ); - addCommonArgs( true, true, aOutputIsDir ); + addCommonArgs( true, true, false, aOutputIsDir ); addDrawingSheetArg(); addDefineArg(); @@ -151,4 +151,4 @@ int CLI::SCH_EXPORT_PLOT_COMMAND::doPerform( KIWAY& aKiway ) int exitCode = aKiway.ProcessJob( KIWAY::FACE_SCH, plotJob.get() ); return exitCode; -} \ No newline at end of file +} diff --git a/kicad/cli/command_sch_export_pythonbom.cpp b/kicad/cli/command_sch_export_pythonbom.cpp index 7864a85031..eaf8385d55 100644 --- a/kicad/cli/command_sch_export_pythonbom.cpp +++ b/kicad/cli/command_sch_export_pythonbom.cpp @@ -31,7 +31,7 @@ CLI::SCH_EXPORT_PYTHONBOM_COMMAND::SCH_EXPORT_PYTHONBOM_COMMAND() : COMMAND( "python-bom" ) { - addCommonArgs( true, true, false ); + addCommonArgs( true, true, false, false ); m_argParser.add_description( UTF8STDSTR( _( "Export the legacy bom xml format used in the " "schematic editor with python scripts" ) ) ); @@ -56,4 +56,4 @@ int CLI::SCH_EXPORT_PYTHONBOM_COMMAND::doPerform( KIWAY& aKiway ) int exitCode = aKiway.ProcessJob( KIWAY::FACE_SCH, bomJob.get() ); return exitCode; -} \ No newline at end of file +} diff --git a/kicad/cli/command_sym_export_svg.cpp b/kicad/cli/command_sym_export_svg.cpp index e61ce51480..8586a9f9f1 100644 --- a/kicad/cli/command_sym_export_svg.cpp +++ b/kicad/cli/command_sym_export_svg.cpp @@ -36,7 +36,7 @@ CLI::SYM_EXPORT_SVG_COMMAND::SYM_EXPORT_SVG_COMMAND() : COMMAND( "svg" ) { - addCommonArgs( true, true, false ); + addCommonArgs( true, true, false, true ); m_argParser.add_description( UTF8STDSTR( _( "Exports the symbol or entire symbol library to SVG" ) ) ); diff --git a/kicad/cli/command_sym_upgrade.cpp b/kicad/cli/command_sym_upgrade.cpp index 25a0c725f5..96c6245bc9 100644 --- a/kicad/cli/command_sym_upgrade.cpp +++ b/kicad/cli/command_sym_upgrade.cpp @@ -32,7 +32,7 @@ CLI::SYM_UPGRADE_COMMAND::SYM_UPGRADE_COMMAND() : COMMAND( "upgrade" ) { - addCommonArgs( true, true, false ); + addCommonArgs( true, true, false, false ); m_argParser.add_description( UTF8STDSTR( _( "Upgrades the symbol library to the current kicad version format" ) ) ); @@ -61,4 +61,4 @@ int CLI::SYM_UPGRADE_COMMAND::doPerform( KIWAY& aKiway ) int exitCode = aKiway.ProcessJob( KIWAY::FACE_SCH, symJob.get() ); return exitCode; -} \ No newline at end of file +}