catalog_path_flag cat_path{cmd}; | catalog_path_flag cat_path{cmd}; | ||||
args::Flag import_stdin{cmd, "stdin", "Import JSON from stdin", {"stdin"}}; | 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> | args::ValueFlagList<std::string> | ||||
json_paths{cmd, | json_paths{cmd, | ||||
"json", | "json", | ||||
int run() { | int run() { | ||||
auto cat = cat_path.open(); | auto cat = cat_path.open(); | ||||
if (init.Get()) { | |||||
cat.import_initial(); | |||||
} | |||||
for (const auto& json_fpath : json_paths.Get()) { | for (const auto& json_fpath : json_paths.Get()) { | ||||
cat.import_json_file(json_fpath); | cat.import_json_file(json_fpath); | ||||
} | } |
store(pkg); | 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); | |||||
} |
std::vector<package_id> by_name(std::string_view sv) const noexcept; | std::vector<package_id> by_name(std::string_view sv) const noexcept; | ||||
std::vector<dependency> dependencies_of(const package_id& pkg) 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_str(std::string_view json_str); | ||||
void import_json_file(path_ref json_path) { | void import_json_file(path_ref json_path) { | ||||
auto content = dds::slurp_file(json_path); | auto content = dds::slurp_file(json_path); |