mirror of
https://github.com/open-goal/jak-project.git
synced 2024-10-20 00:57:44 -04:00
tools: add a flag to just dump all types from all-types
via type searcher (#2098)
This commit is contained in:
parent
09d555b4a0
commit
22ec32ce94
|
@ -1308,6 +1308,14 @@ int TypeSystem::get_size_in_type(const Field& field) const {
|
|||
}
|
||||
}
|
||||
|
||||
std::vector<std::string> TypeSystem::get_all_type_names() {
|
||||
std::vector<std::string> results = {};
|
||||
for (const auto& [type_name, type_info] : m_types) {
|
||||
results.push_back(type_name);
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
std::vector<std::string> TypeSystem::search_types_by_parent_type(
|
||||
const std::string& parent_type,
|
||||
const std::vector<std::string>& existing_matches) {
|
||||
|
|
|
@ -263,6 +263,7 @@ class TypeSystem {
|
|||
m_types_allowed_to_be_redefined.push_back(type_name);
|
||||
}
|
||||
|
||||
std::vector<std::string> get_all_type_names();
|
||||
std::vector<std::string> search_types_by_parent_type(
|
||||
const std::string& parent_type,
|
||||
const std::vector<std::string>& existing_matches = {});
|
||||
|
|
|
@ -24,11 +24,13 @@ int main(int argc, char** argv) {
|
|||
int method_id_min = -1;
|
||||
int type_size = -1;
|
||||
std::string field_json = "";
|
||||
bool get_all = false;
|
||||
|
||||
lg::initialize();
|
||||
|
||||
CLI::App app{"OpenGOAL Type Searcher"};
|
||||
app.add_option("--output-path", output_path, "Where to output the search results file");
|
||||
app.add_flag("-a,--all", get_all, "Just retrieve all possible type names");
|
||||
app.add_option("-g,--game", game_name, "Specify the game name, defaults to 'jak1'");
|
||||
app.add_option("-s,--size", type_size, "The size of the type we are searching for");
|
||||
app.add_option("-m,--method_id", method_id_min,
|
||||
|
@ -61,6 +63,20 @@ int main(int argc, char** argv) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
auto results = nlohmann::json::array({});
|
||||
|
||||
if (get_all) {
|
||||
auto type_names = dts.ts.get_all_type_names();
|
||||
for (const auto& name : type_names) {
|
||||
fmt::print("{}\n", name);
|
||||
results.push_back(name);
|
||||
}
|
||||
|
||||
// Output the results as a json list
|
||||
file_util::write_text_file(output_path.string(), results.dump());
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::vector<std::string> potential_types = {};
|
||||
|
||||
// First filter by parent type is available
|
||||
|
@ -97,7 +113,6 @@ int main(int argc, char** argv) {
|
|||
potential_types = dts.ts.search_types_by_fields(search_fields, potential_types);
|
||||
}
|
||||
|
||||
auto results = nlohmann::json::array({});
|
||||
for (const auto& val : potential_types) {
|
||||
fmt::print("{}\n", val);
|
||||
results.push_back(val);
|
||||
|
|
Loading…
Reference in a new issue