aboutsummaryrefslogtreecommitdiff
path: root/src/libcmd/installable-value.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/libcmd/installable-value.cc')
-rw-r--r--src/libcmd/installable-value.cc22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/libcmd/installable-value.cc b/src/libcmd/installable-value.cc
index 3a7ede4e2..1eff293cc 100644
--- a/src/libcmd/installable-value.cc
+++ b/src/libcmd/installable-value.cc
@@ -41,4 +41,26 @@ ref<InstallableValue> InstallableValue::require(ref<Installable> installable)
return ref { castedInstallable };
}
+std::optional<DerivedPathWithInfo> InstallableValue::trySinglePathToDerivedPaths(Value & v, const PosIdx pos, std::string_view errorCtx)
+{
+ if (v.type() == nPath) {
+ auto storePath = v.path().fetchToStore(state->store);
+ return {{
+ .path = DerivedPath::Opaque {
+ .path = std::move(storePath),
+ },
+ .info = make_ref<ExtraPathInfo>(),
+ }};
+ }
+
+ else if (v.type() == nString) {
+ return {{
+ .path = state->coerceToDerivedPath(pos, v, errorCtx),
+ .info = make_ref<ExtraPathInfo>(),
+ }};
+ }
+
+ else return std::nullopt;
+}
+
}