@@ -170,6 +170,7 @@ struct cli_catalog { | |||
catalog_path_flag cat_path{cmd}; | |||
args::Flag import_stdin{cmd, "stdin", "Import JSON from stdin", {"stdin"}}; | |||
args::Flag init{cmd, "initial", "Re-import the initial catalog contents", {"initial"}}; | |||
args::ValueFlagList<std::string> | |||
json_paths{cmd, | |||
"json", | |||
@@ -178,6 +179,9 @@ struct cli_catalog { | |||
int run() { | |||
auto cat = cat_path.open(); | |||
if (init.Get()) { | |||
cat.import_initial(); | |||
} | |||
for (const auto& json_fpath : json_paths.Get()) { | |||
cat.import_json_file(json_fpath); | |||
} |
@@ -409,3 +409,9 @@ void catalog::import_json_str(std::string_view content) { | |||
store(pkg); | |||
} | |||
} | |||
void catalog::import_initial() { | |||
sqlite3::transaction_guard tr{_db}; | |||
spdlog::info("Restoring built-in initial catalog contents"); | |||
store_init_packages(_db, _stmt_cache); | |||
} |
@@ -39,6 +39,7 @@ public: | |||
std::vector<package_id> by_name(std::string_view sv) const noexcept; | |||
std::vector<dependency> dependencies_of(const package_id& pkg) const noexcept; | |||
void import_initial(); | |||
void import_json_str(std::string_view json_str); | |||
void import_json_file(path_ref json_path) { | |||
auto content = dds::slurp_file(json_path); |