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,
#[command(about = "Print the local alias and device fingerprint")]
Identity,
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 },
}