netsky 0.2.0

netsky CLI: the viable system launcher and subcommand dispatcher
Documentation
use clap::Subcommand;
use netsky_io::{IoCommand, IrohCmd, IrohPairCmd};

#[derive(Subcommand, Debug)]
pub enum IrohCommand {
    Whoami,
    #[command(subcommand)]
    Pair(IrohPairCommand),
    Status {
        #[arg(long)]
        json: bool,
    },
    Send {
        label: String,
        text: String,
    },
}

#[derive(Subcommand, Debug)]
pub enum IrohPairCommand {
    Add { label: String, node_id: String },
    List,
    Remove { label: String },
}

pub fn run(cmd: IrohCommand) -> netsky_core::Result<()> {
    let io = match cmd {
        IrohCommand::Whoami => IoCommand::Iroh(IrohCmd::Whoami),
        IrohCommand::Pair(IrohPairCommand::Add { label, node_id }) => {
            IoCommand::Iroh(IrohCmd::Pair(IrohPairCmd::Add { label, node_id }))
        }
        IrohCommand::Pair(IrohPairCommand::List) => {
            IoCommand::Iroh(IrohCmd::Pair(IrohPairCmd::List))
        }
        IrohCommand::Pair(IrohPairCommand::Remove { label }) => {
            IoCommand::Iroh(IrohCmd::Pair(IrohPairCmd::Remove { label }))
        }
        IrohCommand::Status { json } => IoCommand::Iroh(IrohCmd::Status { json }),
        IrohCommand::Send { label, text } => IoCommand::Iroh(IrohCmd::Send { label, text }),
    };
    crate::cmd::io::run(io)
}