omnimesh 1.0.1

Zero-allocation mesh networking middleware for autonomous robot fleets, edge-AI swarms, and multi-agent systems
Documentation
//! OMNI-MESH CLI Tool
//!
//! Command-line tool for debugging, monitoring, and managing OMNI-MESH nodes.
//!
//! Commands:
//! - inspect: View message details
//! - send: Send test messages
//! - list: List stored messages
//! - stats: Show runtime statistics
//! - metrics: Show Prometheus metrics
//! - trace: Trace message flow
//! - verify: Verify message signatures
//! - store: Inspect DTN store

use clap::{Parser, Subcommand};
use std::path::PathBuf;

#[derive(Parser)]
#[command(name = "omnimesh-cli")]
#[command(about = "OMNI-MESH command-line tool for debugging and monitoring", long_about = None)]
struct Cli {
    #[command(subcommand)]
    command: Commands,
}

#[derive(Subcommand)]
enum Commands {
    /// Inspect a message by ID or file
    Inspect {
        /// Message ID (hex) or path to message file
        #[arg(value_name = "MESSAGE")]
        message: String,

        /// Show full payload content
        #[arg(short, long)]
        full: bool,
    },

    /// Send a test message
    Send {
        /// Sender DID
        #[arg(short, long)]
        from: String,

        /// Recipient DID
        #[arg(short, long)]
        to: String,

        /// Message payload (text or @file)
        #[arg(short, long)]
        payload: String,

        /// Priority (low, normal, high, critical)
        #[arg(short = 'P', long, default_value = "normal")]
        priority: String,

        /// Payload type (raw, robot_command, agent_command, heartbeat, model_weights, sensor_fusion)
        #[arg(short = 'T', long, default_value = "raw")]
        payload_type: String,
    },

    /// List stored messages
    List {
        /// DTN store path
        #[arg(short, long, default_value = "./dtn_store")]
        store: PathBuf,

        /// Filter by sender DID
        #[arg(short, long)]
        from: Option<String>,

        /// Filter by recipient DID
        #[arg(short, long)]
        to: Option<String>,

        /// Limit number of results
        #[arg(short, long, default_value = "10")]
        limit: usize,
    },

    /// Show runtime statistics
    Stats {
        /// Metrics endpoint URL
        #[arg(short, long, default_value = "http://127.0.0.1:9090/metrics")]
        endpoint: String,

        /// Watch mode (refresh every N seconds)
        #[arg(short, long)]
        watch: Option<u64>,
    },

    /// Show Prometheus metrics
    Metrics {
        /// Metrics endpoint URL
        #[arg(short, long, default_value = "http://127.0.0.1:9090/metrics")]
        endpoint: String,

        /// Filter metrics by name pattern
        #[arg(short, long)]
        filter: Option<String>,
    },

    /// Trace message flow
    Trace {
        /// Message ID to trace
        #[arg(value_name = "MESSAGE_ID")]
        message_id: String,

        /// Follow mode (wait for new events)
        #[arg(short, long)]
        follow: bool,
    },

    /// Verify message signature
    Verify {
        /// Path to message file
        #[arg(value_name = "FILE")]
        file: PathBuf,

        /// Show verification details
        #[arg(short, long)]
        verbose: bool,
    },

    /// Inspect DTN store
    Store {
        /// DTN store path
        #[arg(short, long, default_value = "./dtn_store")]
        path: PathBuf,

        /// Show store statistics
        #[arg(short, long)]
        stats: bool,

        /// Show deduplication cache
        #[arg(short, long)]
        dedup: bool,
    },
}

fn main() {
    let cli = Cli::parse();

    match cli.command {
        Commands::Inspect { message, full } => {
            println!("Inspecting message: {}", message);
            println!("Full payload: {}", full);
            println!("\n[Not yet implemented - Week 2 Day 2-3]");
        }

        Commands::Send {
            from,
            to,
            payload,
            priority,
            payload_type,
        } => {
            println!("Sending message:");
            println!("  From: {}", from);
            println!("  To: {}", to);
            println!("  Payload: {}", payload);
            println!("  Priority: {}", priority);
            println!("  Type: {}", payload_type);
            println!("\n[Not yet implemented - Week 2 Day 2-3]");
        }

        Commands::List {
            store,
            from,
            to,
            limit,
        } => {
            println!("Listing messages from: {:?}", store);
            if let Some(f) = from {
                println!("  Filter from: {}", f);
            }
            if let Some(t) = to {
                println!("  Filter to: {}", t);
            }
            println!("  Limit: {}", limit);
            println!("\n[Not yet implemented - Week 2 Day 2-3]");
        }

        Commands::Stats { endpoint, watch } => {
            println!("Fetching stats from: {}", endpoint);
            if let Some(interval) = watch {
                println!("  Watch mode: refresh every {} seconds", interval);
            }
            println!("\n[Not yet implemented - Week 2 Day 2-3]");
        }

        Commands::Metrics { endpoint, filter } => {
            println!("Fetching metrics from: {}", endpoint);
            if let Some(f) = filter {
                println!("  Filter: {}", f);
            }
            println!("\n[Not yet implemented - Week 2 Day 2-3]");
        }

        Commands::Trace { message_id, follow } => {
            println!("Tracing message: {}", message_id);
            println!("Follow mode: {}", follow);
            println!("\n[Not yet implemented - Week 2 Day 2-3]");
        }

        Commands::Verify { file, verbose } => {
            println!("Verifying message from: {:?}", file);
            println!("Verbose: {}", verbose);
            println!("\n[Not yet implemented - Week 2 Day 2-3]");
        }

        Commands::Store { path, stats, dedup } => {
            println!("Inspecting DTN store: {:?}", path);
            println!("Show stats: {}", stats);
            println!("Show dedup: {}", dedup);
            println!("\n[Not yet implemented - Week 2 Day 2-3]");
        }
    }
}