26#include <wx/filename.h>
28#define ARG_TARGET "--target"
29#define ARG_FORCE "--force"
30#define ARG_DRY_RUN "--dry-run"
31#define ARG_LIBRARIES "--libraries"
32#define ARG_VARIANT "--variant"
33#define ARG_DROP_APPROXIMATIONS "--drop-approximations"
34#define ARG_REPORT "--report"
40 m_argParser.add_description(
UTF8STDSTR(
_(
"Export a copy of the schematic readable by an older KiCad version. "
41 "A new --output folder is required except for --dry-run." ) ) );
44 .default_value( std::string() )
46 _(
"Target version name or id, e.g. \"KiCad 10.0\" or \"10.0\". Defaults to the newest." ) ) );
49 .help(
UTF8STDSTR(
_(
"Export even if some features must be dropped or approximated" ) ) )
53 .help(
UTF8STDSTR(
_(
"Print the compatibility report without writing anything" ) ) )
58 _(
"Omit features instead of approximating them; may remove drawing or electrical data" ) ) )
62 .default_value( std::string() )
63 .help(
UTF8STDSTR(
_(
"Also write the compatibility report as text to this file" ) ) );
66 .default_value( std::string() )
68 _(
"Copy this symbol-library folder into the output folder and downgrade the copies" ) ) );
71 .default_value( std::string() )
72 .help(
UTF8STDSTR(
_(
"Flatten this variant into the export. Default is the base design." ) ) );
77 std::unique_ptr<JOB_SCH_DOWNGRADE> job = std::make_unique<JOB_SCH_DOWNGRADE>();
88 if( !wxFile::Exists( job->m_filename ) )
90 wxFprintf( stderr,
_(
"Schematic file does not exist or is not accessible\n" ) );
94 if( !job->m_dryRun && job->m_outputDir.IsEmpty() )
96 wxFprintf( stderr,
_(
"An output folder is required. Use --output.\n" ) );
100 if( !job->m_outputDir.IsEmpty() && !job->m_dryRun )
102 wxFileName inFn( job->m_filename );
103 wxFileName outDir( job->m_outputDir, wxEmptyString );
105 outDir.MakeAbsolute();
106 job->m_outputDir = outDir.GetPath();
108 wxFileName inDir( inFn.GetPath(), wxEmptyString );
110 if( outDir.SameAs( inDir ) )
112 wxFprintf( stderr,
_(
"The output folder must differ from the schematic folder.\n" ) );
118 wxString reportError;
122 wxFprintf( stderr, wxS(
"%s\n" ), reportError );
131 wxFprintf( stderr, wxS(
"%s\n" ), reportError );
argparse::ArgumentParser m_argParser
COMMAND(const std::string &aName)
Define a new COMMAND instance.
void addCommonArgs(bool aInput, bool aOutput, IO_TYPE aInputType, IO_TYPE aOutputType)
Set up the most common of args used across cli.
wxString m_argOutput
Value of the output arg if configured.
wxString m_argInput
Value of the common input arg if configured.
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
int ProcessJob(KIWAY::FACE_T aFace, JOB *aJob, REPORTER *aReporter=nullptr, PROGRESS_REPORTER *aProgressReporter=nullptr)
#define ARG_DROP_APPROXIMATIONS
bool ValidateDowngradeReportPath(const wxString &aPath, wxString &aError)
A report destination that is a design or library file is a mistyped path, not a report.
bool WriteDowngradeReport(const COMPATIBILITY_REPORT &aReport, const wxString &aTarget, const wxString &aPath, wxString &aError)
Write the readable compatibility report, the same text the export dialog shows.
static const int ERR_ARGS
static const int ERR_INVALID_INPUT_FILE
int doPerform(KIWAY &aKiway) override
The internal handler that should be overloaded to implement command specific processing and work.