forked from lix-project/lix
Display valid installable in InstallableDerivedPath::parse warning
The warning message should produce an installable name that can be passed to `nix build`, `nix path-info`, etc. again. Since the CLI expects that the .drv path and the output names are separated by a caret, the warning message must also separate the .drv path and output names with a caret. However, `DerivedPath::Built.to_string()` uses an exclamation point as the separator instead. This commit adds a `separator` argument to the to_string method. This changes the warning message from: If this command is now failing try again with '/nix/store/foo.drv!*' to: If this command is now failing try again with '/nix/store/foo.drv^*'
This commit is contained in:
parent
ef0b48377d
commit
9e8f209036
3 changed files with 10 additions and 9 deletions
|
@ -47,7 +47,7 @@ InstallableDerivedPath InstallableDerivedPath::parse(
|
|||
};
|
||||
warn(
|
||||
"The interpretation of store paths arguments ending in `.drv` recently changed. If this command is now failing try again with '%s'",
|
||||
oldDerivedPath.to_string(*store));
|
||||
oldDerivedPath.to_string(*store, '^'));
|
||||
};
|
||||
return DerivedPath::Opaque {
|
||||
.path = std::move(storePath),
|
||||
|
|
|
@ -59,18 +59,19 @@ std::string DerivedPath::Opaque::to_string(const Store & store) const
|
|||
return store.printStorePath(path);
|
||||
}
|
||||
|
||||
std::string DerivedPath::Built::to_string(const Store & store) const
|
||||
std::string DerivedPath::Built::to_string(const Store & store, char separator) const
|
||||
{
|
||||
return store.printStorePath(drvPath)
|
||||
+ "!"
|
||||
+ separator
|
||||
+ outputs.to_string();
|
||||
}
|
||||
|
||||
std::string DerivedPath::to_string(const Store & store) const
|
||||
std::string DerivedPath::to_string(const Store & store, char separator) const
|
||||
{
|
||||
return std::visit(
|
||||
[&](const auto & req) { return req.to_string(store); },
|
||||
this->raw());
|
||||
return std::visit(overloaded {
|
||||
[&](const DerivedPath::Built & req) { return req.to_string(store, separator); },
|
||||
[&](const DerivedPath::Opaque & req) { return req.to_string(store); },
|
||||
}, this->raw());
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ struct DerivedPathBuilt {
|
|||
StorePath drvPath;
|
||||
OutputsSpec outputs;
|
||||
|
||||
std::string to_string(const Store & store) const;
|
||||
std::string to_string(const Store & store, char separator = '!') const;
|
||||
static DerivedPathBuilt parse(const Store & store, std::string_view, std::string_view);
|
||||
nlohmann::json toJSON(ref<Store> store) const;
|
||||
|
||||
|
@ -81,7 +81,7 @@ struct DerivedPath : _DerivedPathRaw {
|
|||
return static_cast<const Raw &>(*this);
|
||||
}
|
||||
|
||||
std::string to_string(const Store & store) const;
|
||||
std::string to_string(const Store & store, char separator = '!') const;
|
||||
static DerivedPath parse(const Store & store, std::string_view);
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue