mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-09-14 02:03:12 +02:00
Allow running jobsets in cli by description (and uuid)
Fixes https://gitlab.com/kicad/code/kicad/-/issues/20033
This commit is contained in:
parent
8e97a98fef
commit
2d327d9d73
@ -36,7 +36,7 @@
|
||||
const int jobsFileSchemaVersion = 1;
|
||||
|
||||
|
||||
KICOMMON_API std::map<JOBSET_DESTINATION_T, JOBSET_DESTINATION_T_INFO> JobsetDestinationTypeInfos =
|
||||
KICOMMON_API std::map<JOBSET_DESTINATION_T, JOBSET_DESTINATION_T_INFO> JobsetDestinationTypeInfos =
|
||||
{
|
||||
{ JOBSET_DESTINATION_T::FOLDER,
|
||||
{ _HKI( "Folder" ), BITMAPS::small_folder, true, "" } },
|
||||
@ -286,16 +286,24 @@ bool JOBSET::SaveToFile( const wxString& aDirectory, bool aForce )
|
||||
}
|
||||
|
||||
|
||||
JOBSET_DESTINATION* JOBSET::GetDestination( wxString& aDestination )
|
||||
JOBSET_DESTINATION* JOBSET::FindDestination( wxString& aDestinationStr )
|
||||
{
|
||||
auto it = std::find_if( m_destinations.begin(), m_destinations.end(),
|
||||
[&]( const JOBSET_DESTINATION& destination )
|
||||
{
|
||||
if( destination.m_id == aDestination )
|
||||
return true;
|
||||
auto is_matching_dest = [&]( const JOBSET_DESTINATION& destination )
|
||||
{
|
||||
if( destination.m_id == aDestinationStr || destination.m_description == aDestinationStr )
|
||||
return true;
|
||||
|
||||
return false;
|
||||
} );
|
||||
return false;
|
||||
};
|
||||
|
||||
auto count = std::count_if( m_destinations.begin(), m_destinations.end(), is_matching_dest );
|
||||
|
||||
// we want to intentionally fail if more than one matching dest exists
|
||||
// as theres no good way to handle it
|
||||
if( count != 1 )
|
||||
return nullptr;
|
||||
|
||||
auto it = std::find_if( m_destinations.begin(), m_destinations.end(), is_matching_dest );
|
||||
|
||||
if( it != m_destinations.end() )
|
||||
return &(*it);
|
||||
|
@ -120,7 +120,11 @@ public:
|
||||
|
||||
std::vector<JOBSET_DESTINATION>& GetDestinations() { return m_destinations; }
|
||||
|
||||
JOBSET_DESTINATION* GetDestination( wxString& aDestination );
|
||||
/**
|
||||
* Attempts to find a destination based on the given string
|
||||
* Both the uuid of the destination and description name are used
|
||||
*/
|
||||
JOBSET_DESTINATION* FindDestination( wxString& aDestinationStr );
|
||||
|
||||
bool SaveToFile( const wxString& aDirectory = "", bool aForce = false ) override;
|
||||
|
||||
|
@ -87,7 +87,7 @@ int CLI::JOBSET_RUN_COMMAND::doPerform( KIWAY& aKiway )
|
||||
|
||||
if( !outputKey.IsEmpty() )
|
||||
{
|
||||
JOBSET_DESTINATION* destination = jobFile.GetDestination( outputKey );
|
||||
JOBSET_DESTINATION* destination = jobFile.FindDestination( outputKey );
|
||||
|
||||
if( destination == nullptr || !jobsRunner.RunJobsForDestination( destination, bail ) )
|
||||
return_code = CLI::EXIT_CODES::ERR_JOBS_RUN_FAILED;
|
||||
|
Loading…
x
Reference in New Issue
Block a user