CLI: parameterize whether export job inputs are directories or files
This commit is contained in:
parent
1635df57a3
commit
5dc62368b0
|
@ -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_hasInputArg = aInput;
|
||||||
m_hasOutputArg = aOutput;
|
m_hasOutputArg = aOutput;
|
||||||
|
@ -120,9 +120,18 @@ void CLI::COMMAND::addCommonArgs( bool aInput, bool aOutput, bool aOutputIsDir )
|
||||||
|
|
||||||
if( aInput )
|
if( aInput )
|
||||||
{
|
{
|
||||||
m_argParser.add_argument( ARG_INPUT )
|
if( aInputIsDir )
|
||||||
.help( UTF8STDSTR( _( "Input file" ) ) )
|
{
|
||||||
.metavar( "INPUT_FILE" );
|
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 )
|
if( aOutput )
|
||||||
|
@ -138,7 +147,7 @@ void CLI::COMMAND::addCommonArgs( bool aInput, bool aOutput, bool aOutputIsDir )
|
||||||
{
|
{
|
||||||
m_argParser.add_argument( "-o", ARG_OUTPUT )
|
m_argParser.add_argument( "-o", ARG_OUTPUT )
|
||||||
.default_value( std::string() )
|
.default_value( std::string() )
|
||||||
.help( UTF8STDSTR( _( "Output file name" ) ) )
|
.help( UTF8STDSTR( _( "Output file" ) ) )
|
||||||
.metavar( "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."
|
_( "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'" ) ) )
|
"\nUse in the format of '--define-var key=value' or '-D key=value'" ) ) )
|
||||||
.metavar( "KEY=VALUE" );
|
.metavar( "KEY=VALUE" );
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,9 +67,10 @@ 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 directory
|
||||||
* @param aOutputIsDir Configures whether the output 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
|
* Sets up the drawing sheet arg used by many of the export commands
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
|
|
||||||
#define ARG_FOOTPRINT "--footprint"
|
#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" ) ) );
|
m_argParser.add_description( UTF8STDSTR( _( "Exports the footprint or entire footprint library to SVG" ) ) );
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@
|
||||||
|
|
||||||
#define ARG_FORCE "--force"
|
#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" ) ) );
|
m_argParser.add_description( UTF8STDSTR( _( "Upgrades the footprint library to the current kicad version format" ) ) );
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,7 @@
|
||||||
|
|
||||||
CLI::PCB_DRC_COMMAND::PCB_DRC_COMMAND() : COMMAND( "drc" )
|
CLI::PCB_DRC_COMMAND::PCB_DRC_COMMAND() : COMMAND( "drc" )
|
||||||
{
|
{
|
||||||
addCommonArgs( true, true, false );
|
addCommonArgs( true, true, false, false );
|
||||||
addDefineArg();
|
addDefineArg();
|
||||||
|
|
||||||
m_argParser.add_description( UTF8STDSTR( _( "Runs the Design Rules Check (DRC) on the PCB and creates a report" ) ) );
|
m_argParser.add_description( UTF8STDSTR( _( "Runs the Design Rules Check (DRC) on the PCB and creates a report" ) ) );
|
||||||
|
|
|
@ -55,7 +55,7 @@ CLI::PCB_EXPORT_3D_COMMAND::PCB_EXPORT_3D_COMMAND( const std::string& aNa
|
||||||
m_format( aFormat )
|
m_format( aFormat )
|
||||||
{
|
{
|
||||||
m_argParser.add_description( aDescription );
|
m_argParser.add_description( aDescription );
|
||||||
addCommonArgs( true, true, false );
|
addCommonArgs( true, true, false, false );
|
||||||
addDefineArg();
|
addDefineArg();
|
||||||
|
|
||||||
if( m_format == JOB_EXPORT_PCB_3D::FORMAT::UNKNOWN )
|
if( m_format == JOB_EXPORT_PCB_3D::FORMAT::UNKNOWN )
|
||||||
|
|
|
@ -30,6 +30,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 aOutputIsDir ) :
|
bool aOutputIsDir ) :
|
||||||
COMMAND( aName )
|
COMMAND( aName )
|
||||||
{
|
{
|
||||||
|
@ -37,7 +38,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, aOutputIsDir );
|
addCommonArgs( true, true, aInputIsDir, 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 )
|
||||||
|
|
|
@ -42,7 +42,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 aOutputIsDir = false );
|
PCB_EXPORT_BASE_COMMAND( const std::string& aName, bool aInputIsDir = false, bool aOutputIsDir = false );
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
int doPerform( KIWAY& aKiway ) override;
|
int doPerform( KIWAY& aKiway ) override;
|
||||||
|
|
|
@ -41,7 +41,7 @@
|
||||||
#define ARG_MAP_FORMAT "--map-format"
|
#define ARG_MAP_FORMAT "--map-format"
|
||||||
#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() : PCB_EXPORT_BASE_COMMAND( "drill", false, true )
|
||||||
{
|
{
|
||||||
m_argParser.add_description( UTF8STDSTR( _( "Generate Drill Files" ) ) );
|
m_argParser.add_description( UTF8STDSTR( _( "Generate Drill Files" ) ) );
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,7 @@
|
||||||
|
|
||||||
CLI::SCH_ERC_COMMAND::SCH_ERC_COMMAND() : COMMAND( "erc" )
|
CLI::SCH_ERC_COMMAND::SCH_ERC_COMMAND() : COMMAND( "erc" )
|
||||||
{
|
{
|
||||||
addCommonArgs( true, true, false );
|
addCommonArgs( true, true, false, false );
|
||||||
addDefineArg();
|
addDefineArg();
|
||||||
|
|
||||||
m_argParser.add_description( UTF8STDSTR( _( "Runs the Electrical Rules Check (ERC) on the schematic and creates a report" ) ) );
|
m_argParser.add_description( UTF8STDSTR( _( "Runs the Electrical Rules Check (ERC) on the schematic and creates a report" ) ) );
|
||||||
|
|
|
@ -33,7 +33,7 @@
|
||||||
CLI::SCH_EXPORT_BOM_COMMAND::SCH_EXPORT_BOM_COMMAND() : COMMAND( "bom" )
|
CLI::SCH_EXPORT_BOM_COMMAND::SCH_EXPORT_BOM_COMMAND() : COMMAND( "bom" )
|
||||||
{
|
{
|
||||||
m_argParser.add_description( UTF8STDSTR( _( "Generate a Bill of Material (BOM)" ) ) );
|
m_argParser.add_description( UTF8STDSTR( _( "Generate a Bill of Material (BOM)" ) ) );
|
||||||
addCommonArgs( true, true, false );
|
addCommonArgs( true, true, false, false );
|
||||||
|
|
||||||
// Field output options
|
// Field output options
|
||||||
m_argParser.add_argument( ARG_FIELDS )
|
m_argParser.add_argument( ARG_FIELDS )
|
||||||
|
|
|
@ -33,7 +33,7 @@
|
||||||
CLI::SCH_EXPORT_NETLIST_COMMAND::SCH_EXPORT_NETLIST_COMMAND() : COMMAND( "netlist" )
|
CLI::SCH_EXPORT_NETLIST_COMMAND::SCH_EXPORT_NETLIST_COMMAND() : COMMAND( "netlist" )
|
||||||
{
|
{
|
||||||
m_argParser.add_description( UTF8STDSTR( _( "Export a Netlist" ) ) );
|
m_argParser.add_description( UTF8STDSTR( _( "Export a Netlist" ) ) );
|
||||||
addCommonArgs( true, true, false );
|
addCommonArgs( true, true, false, false );
|
||||||
|
|
||||||
m_argParser.add_argument( ARG_FORMAT )
|
m_argParser.add_argument( ARG_FORMAT )
|
||||||
.default_value( std::string( "kicadsexpr" ) )
|
.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() );
|
int exitCode = aKiway.ProcessJob( KIWAY::FACE_SCH, netJob.get() );
|
||||||
|
|
||||||
return exitCode;
|
return exitCode;
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,7 @@ CLI::SCH_EXPORT_PLOT_COMMAND::SCH_EXPORT_PLOT_COMMAND( const std::string& aName,
|
||||||
{
|
{
|
||||||
m_argParser.add_description( aDescription );
|
m_argParser.add_description( aDescription );
|
||||||
|
|
||||||
addCommonArgs( true, true, aOutputIsDir );
|
addCommonArgs( true, true, false, aOutputIsDir );
|
||||||
addDrawingSheetArg();
|
addDrawingSheetArg();
|
||||||
addDefineArg();
|
addDefineArg();
|
||||||
|
|
||||||
|
@ -151,4 +151,4 @@ int CLI::SCH_EXPORT_PLOT_COMMAND::doPerform( KIWAY& aKiway )
|
||||||
int exitCode = aKiway.ProcessJob( KIWAY::FACE_SCH, plotJob.get() );
|
int exitCode = aKiway.ProcessJob( KIWAY::FACE_SCH, plotJob.get() );
|
||||||
|
|
||||||
return exitCode;
|
return exitCode;
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
CLI::SCH_EXPORT_PYTHONBOM_COMMAND::SCH_EXPORT_PYTHONBOM_COMMAND() :
|
CLI::SCH_EXPORT_PYTHONBOM_COMMAND::SCH_EXPORT_PYTHONBOM_COMMAND() :
|
||||||
COMMAND( "python-bom" )
|
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 "
|
m_argParser.add_description( UTF8STDSTR( _( "Export the legacy bom xml format used in the "
|
||||||
"schematic editor with python scripts" ) ) );
|
"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() );
|
int exitCode = aKiway.ProcessJob( KIWAY::FACE_SCH, bomJob.get() );
|
||||||
|
|
||||||
return exitCode;
|
return exitCode;
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,7 @@
|
||||||
|
|
||||||
CLI::SYM_EXPORT_SVG_COMMAND::SYM_EXPORT_SVG_COMMAND() : COMMAND( "svg" )
|
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" ) ) );
|
m_argParser.add_description( UTF8STDSTR( _( "Exports the symbol or entire symbol library to SVG" ) ) );
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
|
|
||||||
CLI::SYM_UPGRADE_COMMAND::SYM_UPGRADE_COMMAND() : COMMAND( "upgrade" )
|
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" ) ) );
|
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() );
|
int exitCode = aKiway.ProcessJob( KIWAY::FACE_SCH, symJob.get() );
|
||||||
|
|
||||||
return exitCode;
|
return exitCode;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue