kicad-cli: support * wildcard in BOM export
Fixes: https://gitlab.com/kicad/code/kicad/-/issues/16086
This commit is contained in:
parent
5734a55515
commit
eb5e327086
|
@ -449,6 +449,46 @@ int EESCHEMA_JOBS_HANDLER::JobExportBom( JOB* aJob )
|
|||
|
||||
for( wxString fieldName : aBomJob->m_fieldsOrdered )
|
||||
{
|
||||
// Handle wildcard. We allow the wildcard anywhere in the list, but it needs to respect
|
||||
// fields that come before and after the wildcard.
|
||||
if( fieldName == _( "*" ) )
|
||||
{
|
||||
for( const BOM_FIELD& modelField : dataModel.GetFieldsOrdered() )
|
||||
{
|
||||
struct BOM_FIELD field;
|
||||
|
||||
field.name = modelField.name;
|
||||
field.show = true;
|
||||
field.groupBy = false;
|
||||
field.label = field.name;
|
||||
|
||||
bool fieldAlreadyPresent = false;
|
||||
for( BOM_FIELD& presetField : preset.fieldsOrdered )
|
||||
{
|
||||
if( presetField.name == field.name )
|
||||
{
|
||||
fieldAlreadyPresent = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
bool fieldLaterInList = false;
|
||||
for( const wxString& fieldInList : aBomJob->m_fieldsOrdered )
|
||||
{
|
||||
if( fieldInList == field.name )
|
||||
{
|
||||
fieldLaterInList = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if( !fieldAlreadyPresent && !fieldLaterInList )
|
||||
preset.fieldsOrdered.emplace_back( field );
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
struct BOM_FIELD field;
|
||||
|
||||
field.name = fieldName;
|
||||
|
|
|
@ -53,7 +53,7 @@ namespace CLI
|
|||
|
||||
//Options for controlling the fields and the grouping
|
||||
#define ARG_FIELDS "--fields"
|
||||
#define ARG_FIELDS_DESC "An ordered list of fields to export."
|
||||
#define ARG_FIELDS_DESC "An ordered list of fields to export. Supports * and ${} substitutions."
|
||||
|
||||
#define ARG_LABELS "--labels"
|
||||
#define ARG_LABELS_DESC "An ordered list of labels to apply the exported fields."
|
||||
|
|
Loading…
Reference in New Issue