Fixes for CLI input and output directories.

Plot functions use an output directory.

Those functions that support an input directory also support
input files.
This commit is contained in:
Jeff Young 2025-03-10 20:11:39 +00:00
parent 567da3de91
commit 9ac851b314
12 changed files with 29 additions and 23 deletions

View File

@ -112,7 +112,8 @@ int CLI::COMMAND::doPerform( KIWAY& aKiway )
} }
void CLI::COMMAND::addCommonArgs( bool aInput, bool aOutput, bool aInputIsDir, bool aOutputIsDir ) void CLI::COMMAND::addCommonArgs( bool aInput, bool aOutput, bool aInputCanBeDir,
bool aOutputIsDir )
{ {
m_hasInputArg = aInput; m_hasInputArg = aInput;
m_hasOutputArg = aOutput; m_hasOutputArg = aOutput;
@ -120,18 +121,16 @@ void CLI::COMMAND::addCommonArgs( bool aInput, bool aOutput, bool aInputIsDir, b
if( aInput ) if( aInput )
{ {
if( aInputIsDir ) if( aInputCanBeDir )
{ {
m_argParser.add_argument( ARG_INPUT ) m_argParser.add_argument( ARG_INPUT )
.help( UTF8STDSTR( _( "Input directory" ) ) ) .help( UTF8STDSTR( _( "Input directory" ) ) )
.metavar( "INPUT_DIR" ); .metavar( "INPUT_DIR" );
} }
else
{ m_argParser.add_argument( ARG_INPUT )
m_argParser.add_argument( ARG_INPUT ) .help( UTF8STDSTR( _( "Input file" ) ) )
.help( UTF8STDSTR( _( "Input file" ) ) ) .metavar( "INPUT_FILE" );
.metavar( "INPUT_FILE" );
}
} }
if( aOutput ) if( aOutput )

View File

@ -67,12 +67,12 @@ protected:
* *
* @param aInput Configures the input arg * @param aInput Configures the input arg
* @param aOutput Configures the output arg * @param aOutput Configures the output arg
* @param aInputIsDir Configures whether the input arg description will be for a file or * @param aInputCanBeDir Configures whether the input arg description will be for either a
* directory * file or directory
* @param aOutputIsDir Configures whether the output arg description will be for a file or * @param aOutputIsDir Configures whether the output arg description will be for a file or
* directory * directory
*/ */
void addCommonArgs( bool aInput, bool aOutput, bool aInputIsDir, bool aOutputIsDir ); void addCommonArgs( bool aInput, bool aOutput, bool aInputCanBeDir, bool aOutputIsDir );
/** /**
* Set up the drawing sheet arg used by many of the export commands * Set up the drawing sheet arg used by many of the export commands

View File

@ -32,7 +32,8 @@
#define ARG_FOOTPRINT "--footprint" #define ARG_FOOTPRINT "--footprint"
CLI::FP_EXPORT_SVG_COMMAND::FP_EXPORT_SVG_COMMAND() : PCB_EXPORT_BASE_COMMAND( "svg", true, true ) CLI::FP_EXPORT_SVG_COMMAND::FP_EXPORT_SVG_COMMAND() :
PCB_EXPORT_BASE_COMMAND( "svg", true, true )
{ {
m_argParser.add_description( UTF8STDSTR( _( "Exports the footprint or entire footprint " m_argParser.add_description( UTF8STDSTR( _( "Exports the footprint or entire footprint "
"library to SVG" ) ) ); "library to SVG" ) ) );

View File

@ -30,7 +30,8 @@
#define ARG_FORCE "--force" #define ARG_FORCE "--force"
CLI::FP_UPGRADE_COMMAND::FP_UPGRADE_COMMAND() : PCB_EXPORT_BASE_COMMAND( "upgrade", true, true ) 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 " m_argParser.add_description( UTF8STDSTR( _( "Upgrades the footprint library to the current "
"kicad version format" ) ) ); "kicad version format" ) ) );

View File

@ -32,7 +32,7 @@
#include <wx/crt.h> #include <wx/crt.h>
CLI::PCB_EXPORT_BASE_COMMAND::PCB_EXPORT_BASE_COMMAND( const std::string& aName, CLI::PCB_EXPORT_BASE_COMMAND::PCB_EXPORT_BASE_COMMAND( const std::string& aName,
bool aInputIsDir, bool aInputCanBeDir,
bool aOutputIsDir ) : bool aOutputIsDir ) :
COMMAND( aName ) COMMAND( aName )
{ {
@ -40,7 +40,7 @@ CLI::PCB_EXPORT_BASE_COMMAND::PCB_EXPORT_BASE_COMMAND( const std::string& aName,
m_requireLayers = false; m_requireLayers = false;
m_hasLayerArg = false; m_hasLayerArg = false;
addCommonArgs( true, true, aInputIsDir, aOutputIsDir ); addCommonArgs( true, true, aInputCanBeDir, aOutputIsDir );
// Build list of layer names and their layer mask: // Build list of layer names and their layer mask:
for( int layer = 0; layer < PCB_LAYER_ID_COUNT; ++layer ) for( int layer = 0; layer < PCB_LAYER_ID_COUNT; ++layer )

View File

@ -70,7 +70,7 @@ namespace CLI
struct PCB_EXPORT_BASE_COMMAND : public COMMAND struct PCB_EXPORT_BASE_COMMAND : public COMMAND
{ {
PCB_EXPORT_BASE_COMMAND( const std::string& aName, bool aInputIsDir = false, PCB_EXPORT_BASE_COMMAND( const std::string& aName, bool aInputCanBeDir = false,
bool aOutputIsDir = false ); bool aOutputIsDir = false );
protected: protected:

View File

@ -43,8 +43,8 @@
#define ARG_DRILL_ORIGIN "--drill-origin" #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() :
false, true ) PCB_EXPORT_BASE_COMMAND( "drill", false, true )
{ {
m_argParser.add_description( UTF8STDSTR( _( "Generate Drill Files" ) ) ); m_argParser.add_description( UTF8STDSTR( _( "Generate Drill Files" ) ) );

View File

@ -37,7 +37,8 @@
#define ARG_MODE_SINGLE "--mode-single" #define ARG_MODE_SINGLE "--mode-single"
#define ARG_MODE_MULTI "--mode-multi" #define ARG_MODE_MULTI "--mode-multi"
CLI::PCB_EXPORT_DXF_COMMAND::PCB_EXPORT_DXF_COMMAND() : PCB_EXPORT_BASE_COMMAND( "dxf" ) CLI::PCB_EXPORT_DXF_COMMAND::PCB_EXPORT_DXF_COMMAND() :
PCB_EXPORT_BASE_COMMAND( "dxf", false, true )
{ {
m_argParser.add_description( UTF8STDSTR( _( "Generate a DXF from a list of layers" ) ) ); m_argParser.add_description( UTF8STDSTR( _( "Generate a DXF from a list of layers" ) ) );

View File

@ -32,7 +32,8 @@
#include <locale_io.h> #include <locale_io.h>
CLI::PCB_EXPORT_GENCAD_COMMAND::PCB_EXPORT_GENCAD_COMMAND() : PCB_EXPORT_BASE_COMMAND( "gencad" ) CLI::PCB_EXPORT_GENCAD_COMMAND::PCB_EXPORT_GENCAD_COMMAND() :
PCB_EXPORT_BASE_COMMAND( "gencad", false, true )
{ {
// TODO: Update string to remove reference to layers // TODO: Update string to remove reference to layers
m_argParser.add_description( UTF8STDSTR( _( "Generate Gencad from a list of layers" ) ) ); m_argParser.add_description( UTF8STDSTR( _( "Generate Gencad from a list of layers" ) ) );

View File

@ -32,7 +32,8 @@
#define ARG_MODE_MULTIPAGE "--mode-multipage" #define ARG_MODE_MULTIPAGE "--mode-multipage"
#define ARG_MODE_SINGLE "--mode-single" #define ARG_MODE_SINGLE "--mode-single"
CLI::PCB_EXPORT_PDF_COMMAND::PCB_EXPORT_PDF_COMMAND() : PCB_EXPORT_BASE_COMMAND( "pdf" ) CLI::PCB_EXPORT_PDF_COMMAND::PCB_EXPORT_PDF_COMMAND() :
PCB_EXPORT_BASE_COMMAND( "pdf", false, true )
{ {
m_argParser.add_description( UTF8STDSTR( _( "Generate PDF from a list of layers" ) ) ); m_argParser.add_description( UTF8STDSTR( _( "Generate PDF from a list of layers" ) ) );

View File

@ -41,7 +41,8 @@
#define ARG_GERBER_BOARD_EDGE "--gerber-board-edge" #define ARG_GERBER_BOARD_EDGE "--gerber-board-edge"
CLI::PCB_EXPORT_POS_COMMAND::PCB_EXPORT_POS_COMMAND() : PCB_EXPORT_BASE_COMMAND( "pos" ) CLI::PCB_EXPORT_POS_COMMAND::PCB_EXPORT_POS_COMMAND() :
PCB_EXPORT_BASE_COMMAND( "pos" )
{ {
m_argParser.add_description( UTF8STDSTR( _( "Generate Position File" ) ) ); m_argParser.add_description( UTF8STDSTR( _( "Generate Position File" ) ) );

View File

@ -36,7 +36,8 @@
#define ARG_MODE_SINGLE "--mode-single" #define ARG_MODE_SINGLE "--mode-single"
#define ARG_MODE_MULTI "--mode-multi" #define ARG_MODE_MULTI "--mode-multi"
CLI::PCB_EXPORT_SVG_COMMAND::PCB_EXPORT_SVG_COMMAND() : PCB_EXPORT_BASE_COMMAND( "svg" ) CLI::PCB_EXPORT_SVG_COMMAND::PCB_EXPORT_SVG_COMMAND() :
PCB_EXPORT_BASE_COMMAND( "svg", false, true )
{ {
m_argParser.add_description( UTF8STDSTR( _( "Generate SVG outputs of a given layer list" ) ) ); m_argParser.add_description( UTF8STDSTR( _( "Generate SVG outputs of a given layer list" ) ) );