Pārlūkot izejas kodu

'pkg repo ls' to list registered package repos

default_compile_flags
vector-of-bool pirms 3 gadiem
vecāks
revīzija
18b23ed4f0
5 mainītis faili ar 48 papildinājumiem un 0 dzēšanām
  1. +33
    -0
      src/dds/cli/cmd/pkg_repo_ls.cpp
  2. +3
    -0
      src/dds/cli/dispatch_main.cpp
  3. +4
    -0
      src/dds/cli/options.cpp
  4. +1
    -0
      src/dds/cli/options.hpp
  5. +7
    -0
      tests/test_pkg_db.py

+ 33
- 0
src/dds/cli/cmd/pkg_repo_ls.cpp Parādīt failu

@@ -0,0 +1,33 @@
#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

+ 3
- 0
src/dds/cli/dispatch_main.cpp Parādīt failu

@@ -21,6 +21,7 @@ command pkg_import;
command pkg_ls;
command pkg_repo_add;
command pkg_repo_update;
command pkg_repo_ls;
command repoman_add;
command repoman_import;
command repoman_init;
@@ -57,6 +58,8 @@ int dispatch_main(const options& opts) noexcept {
return cmd::pkg_repo_add(opts);
case cli_pkg_repo_subcommand::update:
return cmd::pkg_repo_update(opts);
case cli_pkg_repo_subcommand::ls:
return cmd::pkg_repo_ls(opts);
case cli_pkg_repo_subcommand::_none_:;
}
neo::unreachable();

+ 4
- 0
src/dds/cli/options.cpp Parādīt failu

@@ -296,6 +296,10 @@ struct setup {
.name = "update",
.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 {

+ 1
- 0
src/dds/cli/options.hpp Parādīt failu

@@ -55,6 +55,7 @@ enum class cli_pkg_repo_subcommand {
_none_,
add,
update,
ls,
};

/**

+ 7
- 0
tests/test_pkg_db.py Parādīt failu

@@ -1,3 +1,4 @@
from dds_ci.dds import DDSWrapper
from dds_ci.testing import Project, RepoFixture


@@ -20,3 +21,9 @@ def test_pkg_get(http_repo: RepoFixture, tmp_project: Project) -> None:
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/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'])

Notiek ielāde…
Atcelt
Saglabāt