aboutsummaryrefslogtreecommitdiff
path: root/src/nix/ping-store.cc
diff options
context:
space:
mode:
authorJohn Ericson <John.Ericson@Obsidian.Systems>2023-02-28 12:46:00 -0500
committerJohn Ericson <John.Ericson@Obsidian.Systems>2023-02-28 12:46:00 -0500
commit5abd643c6d10f2cfa6e26652a9688a0263310094 (patch)
tree2fdb8bf147cb93430ba3ba79a473568e2584e497 /src/nix/ping-store.cc
parente68e8e3cee53ce7debd7c54b0d122d94d1b102a2 (diff)
parentd381248ec0847cacd918480e83a99287f814456a (diff)
Merge branch 'path-info' into ca-drv-exotic
Diffstat (limited to 'src/nix/ping-store.cc')
-rw-r--r--src/nix/ping-store.cc24
1 files changed, 19 insertions, 5 deletions
diff --git a/src/nix/ping-store.cc b/src/nix/ping-store.cc
index 3c3b7bb45..5c44510ab 100644
--- a/src/nix/ping-store.cc
+++ b/src/nix/ping-store.cc
@@ -1,10 +1,13 @@
#include "command.hh"
#include "shared.hh"
#include "store-api.hh"
+#include "finally.hh"
+
+#include <nlohmann/json.hpp>
using namespace nix;
-struct CmdPingStore : StoreCommand
+struct CmdPingStore : StoreCommand, MixJSON
{
std::string description() override
{
@@ -20,10 +23,21 @@ 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;
+ Finally printRes([&]() {
+ logger->cout("%s", res);
+ });
+ res["url"] = store->getUri();
+ store->connect();
+ if (auto version = store->getVersion())
+ res["version"] = *version;
+ }
}
};