2017-10-14 09:37:41 +08:00
|
|
|
#pragma once
|
|
|
|
|
2020-08-01 02:53:42 +08:00
|
|
|
#include <vcpkg/commands.interface.h>
|
2020-07-12 12:07:51 +08:00
|
|
|
|
2017-10-14 09:37:41 +08:00
|
|
|
namespace vcpkg::Commands
|
|
|
|
{
|
|
|
|
template<class T>
|
|
|
|
struct PackageNameAndFunction
|
|
|
|
{
|
|
|
|
std::string name;
|
|
|
|
T function;
|
|
|
|
};
|
|
|
|
|
2020-08-02 04:45:17 +08:00
|
|
|
Span<const PackageNameAndFunction<const BasicCommand*>> get_available_basic_commands();
|
|
|
|
Span<const PackageNameAndFunction<const PathsCommand*>> get_available_paths_commands();
|
|
|
|
Span<const PackageNameAndFunction<const TripletCommand*>> get_available_triplet_commands();
|
2017-10-14 09:37:41 +08:00
|
|
|
|
|
|
|
template<typename T>
|
2020-08-02 04:45:17 +08:00
|
|
|
T find(StringView command_name, Span<const PackageNameAndFunction<T>> available_commands)
|
2017-10-14 09:37:41 +08:00
|
|
|
{
|
|
|
|
for (const PackageNameAndFunction<T>& cmd : available_commands)
|
|
|
|
{
|
|
|
|
if (cmd.name == command_name)
|
|
|
|
{
|
|
|
|
return cmd.function;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// not found
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
}
|