//! `plexus` — user-facing command-line utilities (`ARCHITECTURE.md` §4.2, §5.1).
//!
//! Workalikes for the Reticulum `rnstatus` / `rnpath` / `rnprobe` / `rncp` /
//! `rnid` / `rnx` tools, talking to the daemon over its control socket. v0
//! status: the subcommand surface is defined; behavior lands in Phase 3 (§11.3).

use clap::{Parser, Subcommand};

/// Plexus command-line utilities (v0 skeleton).
#[derive(Debug, Parser)]
#[command(
    name = "plexus",
    version,
    about = "Plexus command-line utilities (v0 skeleton)"
)]
struct Cli {
    /// The utility to run.
    #[command(subcommand)]
    command: Command,
}

/// The available utilities.
#[derive(Debug, Subcommand)]
enum Command {
    /// Show interface and path status (`rnstatus`).
    Status,
    /// Show or request a path to a destination (`rnpath`).
    Path {
        /// Destination hash; omit to list all known paths.
        destination: Option<String>,
    },
    /// Probe a destination for reachability and RTT (`rnprobe`).
    Probe {
        /// Destination hash to probe.
        destination: String,
    },
    /// Copy a file over the mesh (`rncp`).
    Cp {
        /// Source path.
        source: String,
        /// Destination path or address.
        dest: String,
    },
    /// Manage identities (`rnid`).
    Id,
    /// Low-level packet tools (`rnx`).
    X,
}

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let cli = Cli::parse();
    let phase = "behavior lands in Phase 3 (ARCHITECTURE.md §11.3)";
    match cli.command {
        Command::Status => println!("rnstatus: {phase}"),
        Command::Path { destination } => {
            println!(
                "rnpath {}: {phase}",
                destination.as_deref().unwrap_or("(all)")
            );
        }
        Command::Probe { destination } => println!("rnprobe {destination}: {phase}"),
        Command::Cp { source, dest } => println!("rncp {source} -> {dest}: {phase}"),
        Command::Id => println!("rnid: {phase}"),
        Command::X => println!("rnx: {phase}"),
    }
    Ok(())
}
