nix store ping: try to print json if connect() fails aswell

This commit is contained in:
Yorick van Pelt 2023-01-31 15:10:39 +01:00
parent 28648ed784
commit 4f4a6074e4
No known key found for this signature in database
GPG key ID: A36E70F9DC014A15

View file

@ -1,6 +1,7 @@
#include "command.hh"
#include "shared.hh"
#include "store-api.hh"
#include "finally.hh"
#include <nlohmann/json.hpp>
@ -29,11 +30,13 @@ struct CmdPingStore : StoreCommand, MixJSON
notice("Version: %s", *version);
} else {
nlohmann::json res;
Finally printRes([&]() {
logger->cout("%s", res);
});
res["url"] = store->getUri();
store->connect();
if (auto version = store->getVersion())
res["version"] = *version;
logger->cout("%s", res);
}
}
};