Skip to content

Commit

Permalink
Merge pull request #91 from wcampbell0x2a/update-clap-4
Browse files Browse the repository at this point in the history
Update to clap v4
  • Loading branch information
genonullfree authored Oct 31, 2022
2 parents 13e2718 + 9d9a425 commit f756312
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 52 deletions.
42 changes: 6 additions & 36 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
clap = { version = "3", features = ["derive"] }
clap = { version = "4.0.0", features = ["derive"] }
byteorder = "1.4.3"
xxhash-rust = { version = "0.8.2", features = ["xxh3"] }
aes-gcm = "0.10.1"
Expand Down
32 changes: 17 additions & 15 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,72 +26,74 @@ use errors::TeleportError;

#[derive(Clone, Debug, Parser, PartialEq, Eq)]
pub enum Cmd {
/// Start a teleporter in server (receiving) mode
Listen(ListenOpt),
/// Start a teleporter in client (sending) mode
Send(SendOpt),
}

#[derive(Clone, Debug, Parser, PartialEq, Eq)]
pub struct Opt {
/// Command
#[clap(subcommand)]
#[command(subcommand)]
cmd: Cmd,
}

#[derive(Clone, Debug, Parser, PartialEq, Eq)]
pub struct SendOpt {
/// List of filepaths to files that will be teleported
#[clap(short, long, multiple_values = true, default_value = "")]
#[arg(short, long, num_args = ..)]
input: Vec<PathBuf>,

/// Destination teleporter IP address
#[clap(short, long, default_value = "127.0.0.1")]
dest: String,
#[arg(short, long, default_value_t = Ipv4Addr::LOCALHOST)]
dest: Ipv4Addr,

/// Destination teleporter Port
#[clap(short, long, default_value = "9001")]
#[arg(short, long, default_value = "9001")]
port: u16,

/// Overwrite remote file
#[clap(short, long)]
#[arg(short, long)]
overwrite: bool,

/// Recurse into directories on send
#[clap(short, long)]
#[arg(short, long)]
recursive: bool,

/// Encrypt the file transfer using ECDH key-exchange and random keys
#[clap(short, long)]
#[arg(short, long)]
encrypt: bool,

/// Disable delta transfer (overwrite will transfer entire file)
#[clap(short, long)]
#[arg(short, long)]
no_delta: bool,

/// Keep path info (recreate directory path on remote server)
#[clap(short, long)]
#[arg(short, long)]
keep_path: bool,

/// Backup the destination file to a ".bak" extension if it exists and is being overwritten (consecutive runs will replace the *.bak file)
#[clap(short, long)]
#[arg(short, long)]
backup: bool,

/// If the destination file exists, append a ".1" (or next available number) to the filename instead of overwriting
#[clap(short, long)]
#[arg(short, long)]
filename_append: bool,
}

#[derive(Clone, Debug, Parser, PartialEq, Eq)]
pub struct ListenOpt {
/// Allow absolute and relative file paths for transfers (server only) [WARNING: potentially dangerous option, use at your own risk!]
#[clap(long)]
#[arg(long)]
allow_dangerous_filepath: bool,

/// Require encryption for incoming connections to the server
#[clap(short, long)]
#[arg(short, long)]
must_encrypt: bool,

/// Port to listen on
#[clap(short, long, default_value = "9001")]
#[arg(short, long, default_value = "9001")]
port: u16,
}

Expand Down

0 comments on commit f756312

Please sign in to comment.