32 m_argParser( aName,
"", argparse::default_arguments::none ),
52 wxPrintf(
From_UTF8( ss.str().c_str() ) );
75 if( m_hasDrawingSheetArg )
82 std::vector<std::string> defines = m_argParser.get<std::vector<std::string>>(
ARG_DEFINE_VAR_LONG );
84 for(
const std::string& def : defines )
90 if( bits.Count() == 2 )
101 if( m_hasVariantArg && m_argParser.is_used(
ARG_VARIANT ) )
103 std::vector<std::string> variantNames = m_argParser.get<std::vector<std::string>>(
ARG_VARIANT );
105 for(
const std::string&
name : variantNames )
108 if( m_variantsRequireOutputToken
109 && m_argVariantNames.size() > 1
111 && !m_argOutput.IsEmpty() )
113 if( !m_argOutput.Contains( wxS(
"${VARIANT}" ) ) )
115 wxFprintf( stderr,
_(
"When specifying multiple variants, the output path must contain "
116 "${VARIANT} to generate separate output files for each variant.\n" ) );
122 return doPerform( aKiway );
148 .metavar(
"INPUT_FILE" );
155 .metavar(
"INPUT_DIR" );
161 .help(
UTF8STDSTR(
_(
"Input file or directory" ) ) )
162 .metavar(
"INPUT_FILE_OR_DIR" );
171 switch( aOutputType )
176 .default_value( std::string() )
178 .metavar(
"OUTPUT_FILE" );
184 .default_value( std::string() )
186 .metavar(
"OUTPUT_DIR" );
192 .default_value( std::string() )
193 .help(
UTF8STDSTR(
_(
"Output file or directory" ) ) )
194 .metavar(
"OUTPUT_FILE_OR_DIR" );
208 .default_value( std::string() )
209 .help(
UTF8STDSTR(
_(
"Path to drawing sheet, this overrides any existing project "
210 "defined sheet when used" ) ) )
211 .metavar(
"SHEET_PATH" );
220 .default_value( std::vector<std::string>() )
222 .help(
UTF8STDSTR(
_(
"Overrides or adds project variables, can be used multiple times to "
223 "declare multiple variables.\n"
224 "Use in the format of '--define-var key=value' or '-D key=value'" ) ) )
225 .metavar(
"KEY=VALUE" );
235 .default_value( std::vector<std::string>() )
237 .help(
UTF8STDSTR(
_(
"The variant name(s) to output, can be used multiple times to specify "
238 "multiple variants.\n"
239 "When specifying multiple variants, use ${VARIANT} in the output path to "
240 "generate separate files for each variant.\n"
241 "When no --variant argument is provided, the default variant is output." ) ) );
std::string m_name
Name of this command that is exported and used in the cli.
std::map< wxString, wxString > m_argDefineVars
virtual int doPerform(KIWAY &aKiway)
The internal handler that should be overloaded to implement command specific processing and work.
bool m_hasDefineArg
Whether or not the input arg was added for parsing.
argparse::ArgumentParser m_argParser
bool m_hasOutputArg
Whether or not the output arg was added for parsing.
COMMAND(const std::string &aName)
Define a new COMMAND instance.
void addDefineArg()
Set up the drawing sheet arg used by many of the export commands.
void addVariantsArg(bool aRequireOutputToken=true)
Set up the list of variants to output arguement.
int Perform(KIWAY &aKiway)
Entry point to processing commands from args and doing work.
void addCommonArgs(bool aInput, bool aOutput, IO_TYPE aInputType, IO_TYPE aOutputType)
Set up the most common of args used across cli.
bool m_hasInputArg
Whether or not the input arg was added for parsing.
void addDrawingSheetArg()
Set up the drawing sheet arg used by many of the export commands.
bool m_hasVariantArg
Whether or not the input argument for variant names was added for parsing.
bool m_hasDrawingSheetArg
Whether or not the input arg was added for parsing.
bool m_variantsRequireOutputToken
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
#define ARG_DRAWING_SHEET
#define ARG_DEFINE_VAR_LONG
#define ARG_DEFINE_VAR_SHORT
static wxString From_UTF8(const char *cstring)
Convert a UTF8 encoded C string to a wxString for all wxWidgets build modes.
This file contains miscellaneous commonly used macros and functions.
static const int ERR_ARGS
void wxStringSplit(const wxString &aText, wxArrayString &aStrings, wxChar aSplitter)
Split aString to a string list separated at aSplitter.