forked from lix-project/lix
nix store ping: try to print json if connect() fails aswell
This commit is contained in:
parent
28648ed784
commit
4f4a6074e4
|
@ -1,6 +1,7 @@
|
||||||
#include "command.hh"
|
#include "command.hh"
|
||||||
#include "shared.hh"
|
#include "shared.hh"
|
||||||
#include "store-api.hh"
|
#include "store-api.hh"
|
||||||
|
#include "finally.hh"
|
||||||
|
|
||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
|
@ -29,11 +30,13 @@ struct CmdPingStore : StoreCommand, MixJSON
|
||||||
notice("Version: %s", *version);
|
notice("Version: %s", *version);
|
||||||
} else {
|
} else {
|
||||||
nlohmann::json res;
|
nlohmann::json res;
|
||||||
|
Finally printRes([&]() {
|
||||||
|
logger->cout("%s", res);
|
||||||
|
});
|
||||||
res["url"] = store->getUri();
|
res["url"] = store->getUri();
|
||||||
store->connect();
|
store->connect();
|
||||||
if (auto version = store->getVersion())
|
if (auto version = store->getVersion())
|
||||||
res["version"] = *version;
|
res["version"] = *version;
|
||||||
logger->cout("%s", res);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue