aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJonas Diemer <jonasdiemer@gmail.com>2022-08-15 20:15:57 +0000
committerJonas Diemer <jonasdiemer@gmail.com>2022-09-18 18:25:37 +0000
commite2ae526727e0154a1bc618971011788ee24e8748 (patch)
tree395e682abde8f39f4d71fd4a406f473eaec72118 /src
parentcheck status code when restricted; fix formatting (diff)
downloadminiserve-e2ae526727e0154a1bc618971011788ee24e8748.tar.gz
miniserve-e2ae526727e0154a1bc618971011788ee24e8748.zip
Use argument -u instead of --allowed-upload-dir
Diffstat (limited to '')
-rw-r--r--src/args.rs16
-rw-r--r--src/config.rs4
2 files changed, 7 insertions, 13 deletions
diff --git a/src/args.rs b/src/args.rs
index 56c834c..8cd8ffa 100644
--- a/src/args.rs
+++ b/src/args.rs
@@ -108,28 +108,22 @@ pub struct CliArgs {
pub qrcode: bool,
/// Enable file uploading
- #[clap(short = 'u', long = "upload-files")]
- pub file_upload: bool,
-
- /// Allowed upload directories (together with -u)
- ///
- /// If this is set, uploads are only allowed into the provided directories.
- #[clap(long, requires = "file-upload", value_hint = ValueHint::FilePath)]
- pub allowed_upload_dir: Vec<PathBuf>,
+ #[clap(short = 'u', long = "upload-files", value_hint = ValueHint::FilePath, min_values = 0)]
+ pub allowed_upload_dir: Option<Vec<PathBuf>>,
/// Enable creating directories
- #[clap(short = 'U', long = "mkdir", requires = "file-upload")]
+ #[clap(short = 'U', long = "mkdir", requires = "allowed-upload-dir")]
pub mkdir_enabled: bool,
/// Specify uploadable media types
- #[clap(arg_enum, short = 'm', long = "media-type", requires = "file-upload")]
+ #[clap(arg_enum, short = 'm', long = "media-type", requires = "allowed-upload-dir")]
pub media_type: Option<Vec<MediaType>>,
/// Directly specify the uploadable media type expression
#[clap(
short = 'M',
long = "raw-media-type",
- requires = "file-upload",
+ requires = "allowed-upload-dir",
conflicts_with = "media-type"
)]
pub media_type_raw: Option<String>,
diff --git a/src/config.rs b/src/config.rs
index 2b10440..4f794d1 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -250,8 +250,8 @@ impl MiniserveConfig {
overwrite_files: args.overwrite_files,
show_qrcode: args.qrcode,
mkdir_enabled: args.mkdir_enabled,
- file_upload: args.file_upload,
- allowed_upload_dir: args.allowed_upload_dir,
+ file_upload: !args.allowed_upload_dir.is_none(),
+ allowed_upload_dir: args.allowed_upload_dir.unwrap_or(vec![]),
uploadable_media_type,
tar_enabled: args.enable_tar,
tar_gz_enabled: args.enable_tar_gz,