mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-10 08:16:15 +02:00
nix store ping: add --json flag
This commit is contained in:
parent
c79b1582a7
commit
28648ed784
1 changed files with 16 additions and 5 deletions
|
@ -2,9 +2,11 @@
|
|||
#include "shared.hh"
|
||||
#include "store-api.hh"
|
||||
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
using namespace nix;
|
||||
|
||||
struct CmdPingStore : StoreCommand
|
||||
struct CmdPingStore : StoreCommand, MixJSON
|
||||
{
|
||||
std::string description() override
|
||||
{
|
||||
|
@ -20,10 +22,19 @@ struct CmdPingStore : StoreCommand
|
|||
|
||||
void run(ref<Store> store) override
|
||||
{
|
||||
notice("Store URL: %s", store->getUri());
|
||||
store->connect();
|
||||
if (auto version = store->getVersion())
|
||||
notice("Version: %s", *version);
|
||||
if (!json) {
|
||||
notice("Store URL: %s", store->getUri());
|
||||
store->connect();
|
||||
if (auto version = store->getVersion())
|
||||
notice("Version: %s", *version);
|
||||
} else {
|
||||
nlohmann::json res;
|
||||
res["url"] = store->getUri();
|
||||
store->connect();
|
||||
if (auto version = store->getVersion())
|
||||
res["version"] = *version;
|
||||
logger->cout("%s", res);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue