| #include "../options.hpp" | |||||
| #include "./pkg_repo_err_handle.hpp" | |||||
| #include <dds/pkg/db.hpp> | |||||
| #include <dds/pkg/remote.hpp> | |||||
| #include <neo/sqlite3/iter_tuples.hpp> | |||||
| namespace dds::cli::cmd { | |||||
| static int _pkg_repo_ls(const options& opts) { | |||||
| auto pkg_db = opts.open_catalog(); | |||||
| neo::sqlite3::database_ref db = pkg_db.database(); | |||||
| auto st = db.prepare("SELECT name, remote_url, db_mtime FROM dds_pkg_remotes"); | |||||
| auto tups = neo::sqlite3::iter_tuples<std::string, std::string, std::optional<std::string>>(st); | |||||
| for (auto [name, remote_url, mtime] : tups) { | |||||
| fmt::print("Remote '{}':\n", name); | |||||
| fmt::print(" Updates URL: {}\n", remote_url); | |||||
| if (mtime) { | |||||
| fmt::print(" Last Modified: {}\n", *mtime); | |||||
| } | |||||
| fmt::print("\n"); | |||||
| } | |||||
| return 0; | |||||
| } | |||||
| int pkg_repo_ls(const options& opts) { | |||||
| return handle_pkg_repo_remote_errors([&] { return _pkg_repo_ls(opts); }); | |||||
| } | |||||
| } // namespace dds::cli::cmd |
| command pkg_ls; | command pkg_ls; | ||||
| command pkg_repo_add; | command pkg_repo_add; | ||||
| command pkg_repo_update; | command pkg_repo_update; | ||||
| command pkg_repo_ls; | |||||
| command repoman_add; | command repoman_add; | ||||
| command repoman_import; | command repoman_import; | ||||
| command repoman_init; | command repoman_init; | ||||
| return cmd::pkg_repo_add(opts); | return cmd::pkg_repo_add(opts); | ||||
| case cli_pkg_repo_subcommand::update: | case cli_pkg_repo_subcommand::update: | ||||
| return cmd::pkg_repo_update(opts); | return cmd::pkg_repo_update(opts); | ||||
| case cli_pkg_repo_subcommand::ls: | |||||
| return cmd::pkg_repo_ls(opts); | |||||
| case cli_pkg_repo_subcommand::_none_:; | case cli_pkg_repo_subcommand::_none_:; | ||||
| } | } | ||||
| neo::unreachable(); | neo::unreachable(); |
| .name = "update", | .name = "update", | ||||
| .help = "Update package repository information", | .help = "Update package repository information", | ||||
| }); | }); | ||||
| pkg_repo_grp.add_parser({ | |||||
| .name = "ls", | |||||
| .help = "List locally registered package repositories", | |||||
| }); | |||||
| } | } | ||||
| void setup_pkg_repo_add_cmd(argument_parser& pkg_repo_add_cmd) noexcept { | void setup_pkg_repo_add_cmd(argument_parser& pkg_repo_add_cmd) noexcept { |
| _none_, | _none_, | ||||
| add, | add, | ||||
| update, | update, | ||||
| ls, | |||||
| }; | }; | ||||
| /** | /** |
| from dds_ci.dds import DDSWrapper | |||||
| from dds_ci.testing import Project, RepoFixture | from dds_ci.testing import Project, RepoFixture | ||||
| tmp_project.dds.pkg_get('neo-sqlite3@0.3.0') | tmp_project.dds.pkg_get('neo-sqlite3@0.3.0') | ||||
| assert tmp_project.root.joinpath('neo-sqlite3@0.3.0').is_dir() | assert tmp_project.root.joinpath('neo-sqlite3@0.3.0').is_dir() | ||||
| assert tmp_project.root.joinpath('neo-sqlite3@0.3.0/package.jsonc').is_file() | assert tmp_project.root.joinpath('neo-sqlite3@0.3.0/package.jsonc').is_file() | ||||
| def test_pkg_repo(http_repo: RepoFixture, tmp_project: Project) -> None: | |||||
| dds = tmp_project.dds | |||||
| dds.repo_add(http_repo.url) | |||||
| dds.run(['pkg', 'repo', 'ls']) |