1use std::net::SocketAddr;
2use std::path::PathBuf;
3
4use clap::{Args, CommandFactory, Parser, Subcommand};
5
6#[derive(Debug, Parser)]
7#[command(name = "ferry", version, about = "Local-network file transfer")]
8pub struct Cli {
9 #[arg(long, global = true)]
10 pub port: Option<u16>,
11
12 #[arg(long, global = true)]
13 pub bind: Option<String>,
14
15 #[arg(long, global = true)]
16 pub json: bool,
17
18 #[arg(long, global = true)]
19 pub no_discovery: bool,
20
21 #[arg(short, long, global = true)]
22 pub quiet: bool,
23
24 #[arg(short, long, action = clap::ArgAction::Count, global = true)]
25 pub verbose: u8,
26
27 #[command(subcommand)]
28 pub command: Option<Command>,
29}
30
31impl Cli {
32 pub fn clap_command() -> clap::Command {
33 Self::command()
34 }
35}
36
37#[derive(Debug, Subcommand)]
38pub enum Command {
39 Send(SendArgs),
40 Recv(RecvArgs),
41 Peers {
42 #[command(subcommand)]
43 command: Option<PeersCommand>,
44 },
45 Daemon(DaemonArgs),
46 Config,
47 #[command(about = "Print the local alias and device fingerprint")]
48 Identity,
49 Version,
50 Tui,
51}
52
53#[derive(Debug, Args)]
54pub struct SendArgs {
55 #[arg(
56 long,
57 value_name = "FINGERPRINT",
58 help = "Require the receiver certificate to match this full fingerprint"
59 )]
60 pub fingerprint: Option<String>,
61
62 pub peer: String,
63 pub paths: Vec<PathBuf>,
64}
65
66#[derive(Debug, Args)]
67pub struct RecvArgs {
68 #[arg(long)]
69 pub listen: Option<SocketAddr>,
70
71 #[arg(long, value_name = "DIR")]
72 pub dest: Option<PathBuf>,
73
74 #[arg(long)]
75 pub accept_all: bool,
76}
77
78#[derive(Debug, Args)]
79pub struct DaemonArgs {
80 #[arg(long)]
81 pub listen: Option<SocketAddr>,
82
83 #[arg(long, value_name = "DIR")]
84 pub dest: Option<PathBuf>,
85}
86
87#[derive(Debug, Subcommand)]
88pub enum PeersCommand {
89 Trust { fingerprint: String },
90 Forget { fingerprint: String },
91}