nix ls-{nar,store} --json: Respect -R

This commit is contained in:
Eelco Dolstra 2017-11-14 14:31:28 +01:00
parent c8155e9f5f
commit 4db0a9555e
No known key found for this signature in database
GPG key ID: 8170B4726D7198DE
4 changed files with 13 additions and 6 deletions

View file

@ -182,7 +182,8 @@ ref<FSAccessor> makeNarAccessor(ref<const std::string> nar)
return make_ref<NarAccessor>(nar);
}
void listNar(JSONPlaceholder & res, ref<FSAccessor> accessor, const Path & path)
void listNar(JSONPlaceholder & res, ref<FSAccessor> accessor,
const Path & path, bool recurse)
{
auto st = accessor->stat(path);
@ -200,8 +201,11 @@ void listNar(JSONPlaceholder & res, ref<FSAccessor> accessor, const Path & path)
{
auto res2 = obj.object("entries");
for (auto & name : accessor->readDirectory(path)) {
auto res3 = res2.placeholder(name);
listNar(res3, accessor, path + "/" + name);
if (recurse) {
auto res3 = res2.placeholder(name);
listNar(res3, accessor, path + "/" + name, true);
} else
res2.object(name);
}
}
break;