use anyhow::Result;
use clap::{Subcommand, ValueEnum};
pub mod bitcoind;
pub mod probes;
pub mod state;
#[derive(Debug, Clone, Copy, ValueEnum, Default)]
pub enum BitcoindMode {
#[default]
Docker,
External,
}
#[derive(Subcommand, Debug)]
pub enum HarnessAction {
Up {
#[arg(long, default_value = ".")]
monorepo_path: std::path::PathBuf,
#[arg(long, value_enum, default_value_t = BitcoindMode::Docker)]
bitcoind: BitcoindMode,
#[arg(long)]
with_channel: bool,
#[arg(long)]
clean: bool,
},
Status,
Mine { blocks: u32 },
Fund { node: String, btc: f64 },
ChannelOpen { from: String, to: String, sats: u64 },
Pay { from: String, to: String, sats: u64 },
L402 {
from: String,
to: String,
route: String,
payload: String,
},
Invoke { node: String, capability: String, payload: String },
Logs { node: String, #[arg(long)] tail: bool },
Down { #[arg(long)] clean: bool },
}
pub fn run(action: HarnessAction) -> Result<()> {
match action {
HarnessAction::Up { monorepo_path, bitcoind, with_channel, clean } => {
probes::up(monorepo_path, bitcoind, with_channel, clean)
}
HarnessAction::Status => probes::status(),
HarnessAction::Mine { blocks } => probes::mine(blocks),
HarnessAction::Fund { node, btc } => probes::fund(&node, btc),
HarnessAction::ChannelOpen { from, to, sats } => probes::channel_open(&from, &to, sats),
HarnessAction::Pay { from, to, sats } => probes::pay(&from, &to, sats),
HarnessAction::L402 { from, to, route, payload } => {
probes::l402(&from, &to, &route, &payload)
}
HarnessAction::Invoke { node, capability, payload } => {
probes::invoke(&node, &capability, &payload)
}
HarnessAction::Logs { node, tail } => probes::logs(&node, tail),
HarnessAction::Down { clean } => probes::down(clean),
}
}