mirror of
https://github.com/mii443/encrypt.git
synced 2025-08-22 15:05:33 +00:00
make args simply
This commit is contained in:
15
src/args.rs
15
src/args.rs
@ -1,17 +1,14 @@
|
||||
use std::path::PathBuf;
|
||||
|
||||
use clap::Parser;
|
||||
use clap::ValueHint;
|
||||
|
||||
#[derive(Parser, Debug)]
|
||||
#[clap(author, version, about, long_about = None)]
|
||||
pub struct Args {
|
||||
#[clap(short, long, value_parser)]
|
||||
pub mode: String,
|
||||
|
||||
#[clap(short, long, value_parser)]
|
||||
pub file: Option<String>,
|
||||
|
||||
#[clap(short, long, value_parser)]
|
||||
pub ip: Option<String>,
|
||||
|
||||
#[clap(short, long, value_parser)]
|
||||
pub port: Option<u16>,
|
||||
|
||||
#[clap(name = "FILE", value_hint = ValueHint::AnyPath)]
|
||||
pub file: Option<PathBuf>,
|
||||
}
|
||||
|
10
src/main.rs
10
src/main.rs
@ -16,15 +16,9 @@ fn main() {
|
||||
env_logger::init();
|
||||
let args = Args::parse();
|
||||
|
||||
match &*args.mode {
|
||||
"server" => {
|
||||
if let Some(_) = args.port {
|
||||
start_server(args);
|
||||
}
|
||||
"client" => {
|
||||
} else {
|
||||
start_client(args);
|
||||
}
|
||||
_ => {
|
||||
println!("Unknown mode");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user