ant-node-manager 0.14.2

A command-line application for installing, managing and operating antnode as a service.
Documentation
// Copyright (C) 2024 MaidSafe.net limited.
//
// This SAFE Network Software is licensed to you under The General Public License (GPL), version 3.
// Unless required by applicable law or agreed to in writing, the SAFE Network Software distributed
// under the GPL Licence is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. Please review the Licences for the specific language governing
// permissions and limitations relating to use of the SAFE Network Software.

#![allow(clippy::unused_async)]

use ant_service_management::StatusSummary;
use assert_cmd::cargo::cargo_bin_cmd;
use color_eyre::{Result, eyre::eyre};

pub async fn get_service_status() -> Result<StatusSummary> {
    let mut cmd = cargo_bin_cmd!("antctl");
    let output = cmd
        .arg("status")
        .arg("--json")
        .assert()
        .success()
        .get_output()
        .stdout
        .clone();

    let output = std::str::from_utf8(&output)?;
    println!("status command output:");
    println!("{output}");

    let status: StatusSummary = match serde_json::from_str(output) {
        Ok(json) => json,
        Err(e) => return Err(eyre!("Failed to parse JSON output: {:?}", e)),
    };
    Ok(status)
}