[M5] cargoxx add without version (wildcard)
This commit is contained in:
@@ -19,15 +19,10 @@ auto cmd_add(const fs::path& project_root, const std::string& name,
|
||||
"", std::nullopt, std::nullopt,
|
||||
});
|
||||
}
|
||||
if (version_spec.empty()) {
|
||||
return std::unexpected(util::Error{
|
||||
util::ErrorCode::ManifestVersionInvalid,
|
||||
std::format("version required for '{}'", name),
|
||||
"use the form 'cargoxx add <pkg>@<version>' "
|
||||
"(auto-resolve against nixhub is deferred)",
|
||||
std::nullopt, std::nullopt,
|
||||
});
|
||||
}
|
||||
// Empty version → wildcard. The generated flake.nix tracks `nixos-unstable`
|
||||
// and the linkdb resolver picks whichever recipe is listed first for the
|
||||
// package. Concrete versions land when the resolver against nixhub.io ships.
|
||||
const std::string effective_version = version_spec.empty() ? std::string{"*"} : version_spec;
|
||||
|
||||
auto manifest_path = project_root / "Cargoxx.toml";
|
||||
auto m = manifest::parse(manifest_path);
|
||||
@@ -50,13 +45,13 @@ auto cmd_add(const fs::path& project_root, const std::string& name,
|
||||
if (!db) {
|
||||
return std::unexpected(db.error());
|
||||
}
|
||||
if (auto check = db->resolve(name, version_spec, components); !check) {
|
||||
if (auto check = db->resolve(name, effective_version, components); !check) {
|
||||
return std::unexpected(check.error());
|
||||
}
|
||||
|
||||
m->dependencies.push_back(manifest::Dependency{
|
||||
.name = name,
|
||||
.version_spec = version_spec,
|
||||
.version_spec = effective_version,
|
||||
.components = std::move(components),
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user