diff --git a/app/plugins/batch_mode/batch_mode.cpp b/app/plugins/batch_mode/batch_mode.cpp index cc9196d57..cf78b9a54 100644 --- a/app/plugins/batch_mode/batch_mode.cpp +++ b/app/plugins/batch_mode/batch_mode.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2020-2023, Arm Limited and Contributors +/* Copyright (c) 2020-2024, Arm Limited and Contributors * * SPDX-License-Identifier: Apache-2.0 * @@ -65,7 +65,30 @@ void BatchMode::init(const vkb::CommandParser &parser) categories = parser.as>(&categories_flag); } + std::unordered_set skips; + if (parser.contains(&skip_flag)) + { + skips = parser.as>(&skip_flag); + } + sample_list = apps::get_samples(categories, tags); + if (!skips.empty()) + { + std::vector filtered_list; + filtered_list.reserve(sample_list.size()); + + std::copy_if( + sample_list.begin(), sample_list.end(), + std::back_inserter(filtered_list), + [&](const apps::AppInfo *app) { + return skips.find(app->id) == skips.end(); + }); + + if (filtered_list.size() != sample_list.size()) + { + sample_list.swap(filtered_list); + } + } if (sample_list.empty()) { diff --git a/app/plugins/batch_mode/batch_mode.h b/app/plugins/batch_mode/batch_mode.h index 61b14f2c3..f7ab9e5b2 100644 --- a/app/plugins/batch_mode/batch_mode.h +++ b/app/plugins/batch_mode/batch_mode.h @@ -32,11 +32,11 @@ using BatchModeTags = vkb::PluginBase #include #include +#include #include namespace vkb @@ -306,6 +307,13 @@ inline bool CommandParser::convert_type(const std::vector &values, return true; } +template <> +inline bool CommandParser::convert_type(const std::vector &values, std::unordered_set *type) const +{ + *type = std::unordered_set(values.begin(), values.end()); + return true; +} + template <> inline bool CommandParser::convert_type(const std::vector &values, std::string *type) const { diff --git a/framework/platform/parsers/CLI11.cpp b/framework/platform/parsers/CLI11.cpp index 48b33374d..9bfd187e7 100644 --- a/framework/platform/parsers/CLI11.cpp +++ b/framework/platform/parsers/CLI11.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2021-2023, Arm Limited and Contributors +/* Copyright (c) 2021-2024, Arm Limited and Contributors * * SPDX-License-Identifier: Apache-2.0 * @@ -17,6 +17,8 @@ #include "CLI11.h" +#include + #include "common/logging.h" #include "common/strings.h" @@ -100,7 +102,8 @@ void CLI11CommandParser::parse(CLI11CommandContext *context, FlagCommand *comman { CLI::Option *flag; - switch (command->get_flag_type()) + auto flagType = command->get_flag_type(); + switch (flagType) { case FlagType::FlagOnly: flag = context->cli11->add_flag(command->get_name(), command->get_help_line()); @@ -109,6 +112,13 @@ void CLI11CommandParser::parse(CLI11CommandContext *context, FlagCommand *comman case FlagType::ManyValues: flag = context->cli11->add_option(command->get_name(), command->get_help_line()); break; + default: + throw std::runtime_error("Unknown flag type"); + } + + if (flagType == FlagType::ManyValues) + { + flag = flag->expected(1, INT_MAX); } _options.emplace(command, flag);