|
|
|
@ -10,47 +10,43 @@ use crate::BoxResult;
@@ -10,47 +10,43 @@ use crate::BoxResult;
|
|
|
|
|
const ABOUT: &str = concat!("\n", crate_description!()); // Add extra newline.
|
|
|
|
|
|
|
|
|
|
fn app() -> clap::Command<'static> { |
|
|
|
|
let arg_port = Arg::new("port") |
|
|
|
|
.short('p') |
|
|
|
|
.long("port") |
|
|
|
|
.default_value("5000") |
|
|
|
|
.help("Specify port to listen on") |
|
|
|
|
.value_name("port"); |
|
|
|
|
|
|
|
|
|
let arg_address = Arg::new("address") |
|
|
|
|
.short('b') |
|
|
|
|
.long("bind") |
|
|
|
|
.default_value("127.0.0.1") |
|
|
|
|
.help("Specify bind address") |
|
|
|
|
.value_name("address"); |
|
|
|
|
|
|
|
|
|
let arg_path = Arg::new("path") |
|
|
|
|
.default_value(".") |
|
|
|
|
.allow_invalid_utf8(true) |
|
|
|
|
.help("Path to a directory for serving files"); |
|
|
|
|
|
|
|
|
|
let arg_static = Arg::new("static") |
|
|
|
|
.long("static") |
|
|
|
|
.help("Only serve static files, disable upload and delete operations"); |
|
|
|
|
|
|
|
|
|
let arg_auth = Arg::new("auth") |
|
|
|
|
.short('a') |
|
|
|
|
.long("auth") |
|
|
|
|
.help("Authenticate with user and pass") |
|
|
|
|
.value_name("user:pass"); |
|
|
|
|
|
|
|
|
|
let arg_no_log = Arg::new("no-log") |
|
|
|
|
.long("--no-log") |
|
|
|
|
.help("Don't log any request/response information."); |
|
|
|
|
|
|
|
|
|
clap::command!() |
|
|
|
|
.about(ABOUT) |
|
|
|
|
.arg(arg_address) |
|
|
|
|
.arg(arg_port) |
|
|
|
|
.arg(arg_path) |
|
|
|
|
.arg(arg_static) |
|
|
|
|
.arg(arg_auth) |
|
|
|
|
.arg(arg_no_log) |
|
|
|
|
.arg( |
|
|
|
|
Arg::new("address") |
|
|
|
|
.short('b') |
|
|
|
|
.long("bind") |
|
|
|
|
.default_value("127.0.0.1") |
|
|
|
|
.help("Specify bind address") |
|
|
|
|
.value_name("address"), |
|
|
|
|
) |
|
|
|
|
.arg( |
|
|
|
|
Arg::new("port") |
|
|
|
|
.short('p') |
|
|
|
|
.long("port") |
|
|
|
|
.default_value("5000") |
|
|
|
|
.help("Specify port to listen on") |
|
|
|
|
.value_name("port"), |
|
|
|
|
) |
|
|
|
|
.arg( |
|
|
|
|
Arg::new("path") |
|
|
|
|
.default_value(".") |
|
|
|
|
.allow_invalid_utf8(true) |
|
|
|
|
.help("Path to a directory for serving files"), |
|
|
|
|
) |
|
|
|
|
.arg( |
|
|
|
|
Arg::new("no-edit") |
|
|
|
|
.short('E') |
|
|
|
|
.long("no-edit") |
|
|
|
|
.help("Disable editing operations such as update or delete"), |
|
|
|
|
) |
|
|
|
|
.arg( |
|
|
|
|
Arg::new("auth") |
|
|
|
|
.short('a') |
|
|
|
|
.long("auth") |
|
|
|
|
.help("Authenticate with user and pass") |
|
|
|
|
.value_name("user:pass"), |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
pub fn matches() -> ArgMatches { |
|
|
|
@ -64,7 +60,6 @@ pub struct Args {
@@ -64,7 +60,6 @@ pub struct Args {
|
|
|
|
|
pub path: PathBuf, |
|
|
|
|
pub readonly: bool, |
|
|
|
|
pub auth: Option<String>, |
|
|
|
|
pub log: bool, |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
impl Args { |
|
|
|
@ -77,9 +72,8 @@ impl Args {
@@ -77,9 +72,8 @@ impl Args {
|
|
|
|
|
let port = matches.value_of_t::<u16>("port")?; |
|
|
|
|
let path = matches.value_of_os("path").unwrap_or_default(); |
|
|
|
|
let path = Args::parse_path(path)?; |
|
|
|
|
let readonly = matches.is_present("static"); |
|
|
|
|
let readonly = matches.is_present("no-edit"); |
|
|
|
|
let auth = matches.value_of("auth").map(|v| v.to_owned()); |
|
|
|
|
let log = !matches.is_present("no-log"); |
|
|
|
|
|
|
|
|
|
Ok(Args { |
|
|
|
|
address, |
|
|
|
@ -87,7 +81,6 @@ impl Args {
@@ -87,7 +81,6 @@ impl Args {
|
|
|
|
|
path, |
|
|
|
|
readonly, |
|
|
|
|
auth, |
|
|
|
|
log, |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|