From 32f31a8c63d35a8ecfd341802465afacbe8d5759 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 22 Jan 2020 17:20:21 +0100 Subject: [PATCH] nix flake info: Don't show empty descriptions --- src/libexpr/flake/flake.hh | 2 +- src/nix/flake.cc | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/libexpr/flake/flake.hh b/src/libexpr/flake/flake.hh index d44113506..afd49436b 100644 --- a/src/libexpr/flake/flake.hh +++ b/src/libexpr/flake/flake.hh @@ -33,7 +33,7 @@ struct Flake { FlakeRef originalRef; FlakeRef resolvedRef; - std::string description; + std::optional description; std::shared_ptr sourceInfo; std::map inputs; Value * vOutputs; // FIXME: gc diff --git a/src/nix/flake.cc b/src/nix/flake.cc index 5bec5903f..bfff682d9 100644 --- a/src/nix/flake.cc +++ b/src/nix/flake.cc @@ -80,7 +80,8 @@ static void printFlakeInfo(const Store & store, const Flake & flake) { std::cout << fmt("URL: %s\n", flake.resolvedRef.input->to_string()); std::cout << fmt("Edition: %s\n", flake.edition); - std::cout << fmt("Description: %s\n", flake.description); + if (flake.description) + std::cout << fmt("Description: %s\n", *flake.description); std::cout << fmt("Path: %s\n", store.printStorePath(flake.sourceInfo->storePath)); if (flake.sourceInfo->rev) std::cout << fmt("Revision: %s\n", flake.sourceInfo->rev->to_string(Base16, false)); @@ -94,7 +95,8 @@ static void printFlakeInfo(const Store & store, const Flake & flake) static nlohmann::json flakeToJson(const Store & store, const Flake & flake) { nlohmann::json j; - j["description"] = flake.description; + if (flake.description) + j["description"] = *flake.description; j["edition"] = flake.edition; j["url"] = flake.resolvedRef.input->to_string(); if (flake.sourceInfo->rev)