ferry-cli 0.1.6

The ferry command for terminal-native LAN file transfer with QUIC, discovery, resume, TUI, and JSON output.
Documentation
use std::net::SocketAddr;
use std::path::PathBuf;

use clap::{Args, CommandFactory, Parser, Subcommand};

#[derive(Debug, Parser)]
#[command(name = "ferry", version, about = "Local-network file transfer")]
pub struct Cli {
    #[arg(long, global = true)]
    pub port: Option<u16>,

    #[arg(long, global = true)]
    pub bind: Option<String>,

    #[arg(long, global = true)]
    pub json: bool,

    #[arg(long, global = true)]
    pub no_discovery: bool,

    #[arg(short, long, global = true)]
    pub quiet: bool,

    #[arg(short, long, action = clap::ArgAction::Count, global = true)]
    pub verbose: u8,

    #[command(subcommand)]
    pub command: Option<Command>,
}

impl Cli {
    pub fn clap_command() -> clap::Command {
        Self::command()
    }
}

#[derive(Debug, Subcommand)]
pub enum Command {
    Send(SendArgs),
    Recv(RecvArgs),
    Peers {
        #[command(subcommand)]
        command: Option<PeersCommand>,
    },
    Daemon(DaemonArgs),
    Config,
    Version,
    Tui,
}

#[derive(Debug, Args)]
pub struct SendArgs {
    #[arg(
        long,
        value_name = "FINGERPRINT",
        help = "Require the receiver certificate to match this full fingerprint"
    )]
    pub fingerprint: Option<String>,

    pub peer: String,
    pub paths: Vec<PathBuf>,
}

#[derive(Debug, Args)]
pub struct RecvArgs {
    #[arg(long)]
    pub listen: Option<SocketAddr>,

    #[arg(long, value_name = "DIR")]
    pub dest: Option<PathBuf>,

    #[arg(long)]
    pub accept_all: bool,
}

#[derive(Debug, Args)]
pub struct DaemonArgs {
    #[arg(long)]
    pub listen: Option<SocketAddr>,

    #[arg(long, value_name = "DIR")]
    pub dest: Option<PathBuf>,
}

#[derive(Debug, Subcommand)]
pub enum PeersCommand {
    Trust { fingerprint: String },
    Forget { fingerprint: String },
}