mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-15 10:46:15 +02:00
nix flake show: add the description if it exists
This commit is contained in:
parent
5a6e28e166
commit
547e808a75
1 changed files with 14 additions and 9 deletions
|
@ -1243,25 +1243,30 @@ struct CmdFlakeShow : FlakeCommand, MixJSON
|
||||||
auto showDerivation = [&]()
|
auto showDerivation = [&]()
|
||||||
{
|
{
|
||||||
auto name = visitor.getAttr(state->sName)->getString();
|
auto name = visitor.getAttr(state->sName)->getString();
|
||||||
if (json) {
|
|
||||||
std::optional<std::string> description;
|
std::optional<std::string> description;
|
||||||
if (auto aMeta = visitor.maybeGetAttr(state->sMeta)) {
|
if (auto aMeta = visitor.maybeGetAttr(state->sMeta)) {
|
||||||
if (auto aDescription = aMeta->maybeGetAttr(state->sDescription))
|
if (auto aDescription = aMeta->maybeGetAttr(state->sDescription))
|
||||||
description = aDescription->getString();
|
description = aDescription->getString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (json) {
|
||||||
j.emplace("type", "derivation");
|
j.emplace("type", "derivation");
|
||||||
j.emplace("name", name);
|
j.emplace("name", name);
|
||||||
if (description)
|
if (description)
|
||||||
j.emplace("description", *description);
|
j.emplace("description", *description);
|
||||||
} else {
|
} else {
|
||||||
logger->cout("%s: %s '%s'",
|
auto type =
|
||||||
headerPrefix,
|
|
||||||
attrPath.size() == 2 && attrPathS[0] == "devShell" ? "development environment" :
|
attrPath.size() == 2 && attrPathS[0] == "devShell" ? "development environment" :
|
||||||
attrPath.size() >= 2 && attrPathS[0] == "devShells" ? "development environment" :
|
attrPath.size() >= 2 && attrPathS[0] == "devShells" ? "development environment" :
|
||||||
attrPath.size() == 3 && attrPathS[0] == "checks" ? "derivation" :
|
attrPath.size() == 3 && attrPathS[0] == "checks" ? "derivation" :
|
||||||
attrPath.size() >= 1 && attrPathS[0] == "hydraJobs" ? "derivation" :
|
attrPath.size() >= 1 && attrPathS[0] == "hydraJobs" ? "derivation" :
|
||||||
"package",
|
"package";
|
||||||
name);
|
if (description) {
|
||||||
|
logger->cout("%s: %s '%s' - '%s'", headerPrefix, type, name, *description);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
logger->cout("%s: %s '%s'", headerPrefix, type, name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue