nix registry list: Show 'dir' attribute

Issue #4050.
This commit is contained in:
Eelco Dolstra 2020-09-29 23:33:16 +02:00
parent e2d398c200
commit 64e9b3c83b
4 changed files with 15 additions and 5 deletions

View file

@ -16,10 +16,10 @@ const static std::string subDirRegex = subDirElemRegex + "(?:/" + subDirElemRege
std::string FlakeRef::to_string() const std::string FlakeRef::to_string() const
{ {
auto url = input.toURL(); std::map<std::string, std::string> extraQuery;
if (subdir != "") if (subdir != "")
url.query.insert_or_assign("dir", subdir); extraQuery.insert_or_assign("dir", subdir);
return url.to_string(); return input.toURLString(extraQuery);
} }
fetchers::Attrs FlakeRef::toAttrs() const fetchers::Attrs FlakeRef::toAttrs() const

View file

@ -69,6 +69,14 @@ ParsedURL Input::toURL() const
return scheme->toURL(*this); return scheme->toURL(*this);
} }
std::string Input::toURLString(const std::map<std::string, std::string> & extraQuery) const
{
auto url = toURL();
for (auto & attr : extraQuery)
url.query.insert(attr);
return url.to_string();
}
std::string Input::to_string() const std::string Input::to_string() const
{ {
return toURL().to_string(); return toURL().to_string();

View file

@ -39,6 +39,8 @@ public:
ParsedURL toURL() const; ParsedURL toURL() const;
std::string toURLString(const std::map<std::string, std::string> & extraQuery = {}) const;
std::string to_string() const; std::string to_string() const;
Attrs toAttrs() const; Attrs toAttrs() const;

View file

@ -31,8 +31,8 @@ struct CmdRegistryList : StoreCommand
registry->type == Registry::User ? "user " : registry->type == Registry::User ? "user " :
registry->type == Registry::System ? "system" : registry->type == Registry::System ? "system" :
"global", "global",
entry.from.to_string(), entry.from.toURLString(),
entry.to.to_string()); entry.to.toURLString(attrsToQuery(entry.extraAttrs)));
} }
} }
} }