Skip to content

Commit

Permalink
nix flake show: Only print up to the first new line if it exists.
Browse files Browse the repository at this point in the history
  • Loading branch information
kjeremy committed Jul 8, 2024
1 parent 4c01250 commit ff1c83b
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/nix/flake.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1253,7 +1253,11 @@ struct CmdFlakeShow : FlakeCommand, MixJSON
attrPath.size() >= 1 && attrPathS[0] == "hydraJobs" ? "derivation" :
"package";
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 {
logger->cout("%s: %s '%s'", headerPrefix, type, name);
Expand Down

0 comments on commit ff1c83b

Please sign in to comment.