Browse Source

Put the obtained sdist in a useful location

default_compile_flags
vector-of-bool 5 years ago
parent
commit
0d23ff3146
2 changed files with 25 additions and 11 deletions
  1. +23
    -11
      src/dds/dds.main.cpp
  2. +2
    -0
      tests/catalog/get_test.py

+ 23
- 11
src/dds/dds.main.cpp View File

} }
}; };


struct repo_where_flag : path_flag {
repo_where_flag(args::Group& grp)
struct repo_path_flag : path_flag {
repo_path_flag(args::Group& grp)
: path_flag{grp, : path_flag{grp,
"dir", "dir",
"Path to the DDS repository directory", "Path to the DDS repository directory",
cli_catalog& parent; cli_catalog& parent;
args::Command cmd{parent.cat_group, "get", "Obtain an sdist from a catalog listing"}; args::Command cmd{parent.cat_group, "get", "Obtain an sdist from a catalog listing"};


catalog_path_flag path{cmd};
catalog_path_flag path{cmd};

path_flag out{cmd,
"out",
"The directory where the source distributions will be placed",
{"out-dir", 'o'},
dds::fs::current_path()};

args::PositionalList<std::string> requirements{cmd, args::PositionalList<std::string> requirements{cmd,
"requirement", "requirement",
"The package IDs to obtain"}; "The package IDs to obtain"};
auto info = cat.get(id); auto info = cat.get(id);
if (!info) { if (!info) {
throw std::runtime_error( throw std::runtime_error(
fmt::format("No package in the catalog matched the given ID"));
fmt::format("No package in the catalog matched the ID '{}'", req));
} }
dds::get_package_sdist(*info);
auto tsd = dds::get_package_sdist(*info);
auto out_path = out.Get();
auto dest = out_path / id.to_string();
spdlog::info("Create sdist at {}", dest.string());
dds::fs::remove_all(dest);
dds::safe_rename(tsd.sdist.path, dest);
} }
return 0; return 0;
} }
args::Command cmd{base.cmd_group, "repo", "Manage the package repository"}; args::Command cmd{base.cmd_group, "repo", "Manage the package repository"};
common_flags _common{cmd}; common_flags _common{cmd};


repo_where_flag where{cmd};
repo_path_flag where{cmd};


args::Group repo_group{cmd, "Repo subcommands"}; args::Group repo_group{cmd, "Repo subcommands"};




common_project_flags project{cmd}; common_project_flags project{cmd};


repo_where_flag repo_where{cmd};
args::Flag force{cmd,
repo_path_flag repo_where{cmd};
args::Flag force{cmd,
"replace-if-exists", "replace-if-exists",
"Replace an existing export in the repository", "Replace an existing export in the repository",
{"replace"}}; {"replace"}};
"Ensure we have local copies of the project dependencies"}; "Ensure we have local copies of the project dependencies"};
common_flags _common{cmd}; common_flags _common{cmd};


repo_where_flag repo_where{cmd};
path_flag remote_listing_file{
repo_path_flag repo_where{cmd};
path_flag remote_listing_file{
cmd, cmd,
"remote-listing", "remote-listing",
"Path to a file containing listing of remote sdists and how to obtain them", "Path to a file containing listing of remote sdists and how to obtain them",
"If specified, will not generate an INDEX.lmi", "If specified, will not generate an INDEX.lmi",
{"skip-lmi"}}; {"skip-lmi"}};


repo_where_flag repo_where{cmd};
repo_path_flag repo_where{cmd};


toolchain_flag tc_filepath{cmd}; toolchain_flag tc_filepath{cmd};



+ 2
- 0
tests/catalog/get_test.py View File

dds.catalog_import(cat_path, json_path) dds.catalog_import(cat_path, json_path)


dds.catalog_get(cat_path, 'neo-sqlite3@0.2.2') dds.catalog_get(cat_path, 'neo-sqlite3@0.2.2')
assert (dds.source_root / 'neo-sqlite3@0.2.2').is_dir()
assert (dds.source_root / 'neo-sqlite3@0.2.2/package.dds').is_file()

Loading…
Cancel
Save