nix flake info: Don't show empty descriptions

This commit is contained in:
Eelco Dolstra 2020-01-22 17:20:21 +01:00
parent 543288b649
commit 32f31a8c63
2 changed files with 5 additions and 3 deletions

View file

@ -33,7 +33,7 @@ struct Flake
{
FlakeRef originalRef;
FlakeRef resolvedRef;
std::string description;
std::optional<std::string> description;
std::shared_ptr<const fetchers::Tree> sourceInfo;
std::map<FlakeId, FlakeInput> inputs;
Value * vOutputs; // FIXME: gc

View file

@ -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)