nix flake show: Only print up to the first new line if it exists.

This commit is contained in:
Jeremy Kolb 2024-07-08 11:56:41 -04:00
parent 547e808a75
commit 07d0527c0c

View file

@ -1262,7 +1262,11 @@ struct CmdFlakeShow : FlakeCommand, MixJSON
attrPath.size() >= 1 && attrPathS[0] == "hydraJobs" ? "derivation" : attrPath.size() >= 1 && attrPathS[0] == "hydraJobs" ? "derivation" :
"package"; "package";
if (description) { if (description) {
logger->cout("%s: %s '%s' - '%s'", headerPrefix, type, name, *description); // Handle new lines in descriptions.
auto index = description->find('\n');
std::string_view sanitized_description(description->data(), index != std::string::npos ? index : description->size());
logger->cout("%s: %s '%s' - '%s'", headerPrefix, type, name, sanitized_description);
} }
else { else {
logger->cout("%s: %s '%s'", headerPrefix, type, name); logger->cout("%s: %s '%s'", headerPrefix, type, name);