diff options
author | Sven-Hendrik Haase <svenstaro@gmail.com> | 2022-10-14 12:04:51 +0000 |
---|---|---|
committer | Sven-Hendrik Haase <svenstaro@gmail.com> | 2022-10-14 12:04:51 +0000 |
commit | 0be49abddf37f13eaa04b3f521a6185560c53f8a (patch) | |
tree | df12234ea99bf855a4d7b8f748a19dbdf8319fc6 | |
parent | Bump deps (diff) | |
download | miniserve-0be49abddf37f13eaa04b3f521a6185560c53f8a.tar.gz miniserve-0be49abddf37f13eaa04b3f521a6185560c53f8a.zip |
Fix clap deprecations
Also update README
-rw-r--r-- | Cargo.toml | 2 | ||||
-rw-r--r-- | README.md | 185 | ||||
-rw-r--r-- | src/args.rs | 71 |
3 files changed, 126 insertions, 132 deletions
@@ -28,7 +28,7 @@ atty = "0.2" bytesize = "1" chrono = "0.4" chrono-humanize = "0.2" -clap = { version = "4", features = ["derive", "cargo", "wrap_help"] } +clap = { version = "4", features = ["derive", "cargo", "wrap_help", "deprecated"] } clap_complete = "4" clap_mangen = "0.2" comrak = { version = "0.14", default-features = false } @@ -112,146 +112,141 @@ Some mobile browsers like Firefox on Android will offer to open the camera app w ## Usage - miniserve 0.22.0 - Sven-Hendrik Haase <svenstaro@gmail.com>, Boastful Squirrel <boastful.squirrel@gmail.com> For when you really just want to serve some files over HTTP right now! - USAGE: - miniserve [OPTIONS] [--] [PATH] + Usage: miniserve [OPTIONS] [PATH] - ARGS: - <PATH> - Which path to serve + Arguments: + [PATH] + Which path to serve - OPTIONS: - -a, --auth <AUTH> - Set authentication. Currently supported formats: username:password, username:sha256:hash, - username:sha512:hash (e.g. joe:123, - joe:sha256:a665a45920422f9d417e4867efdc4fb8a04a1f3fff1fa07e998e86f7f7a27ae3) + Options: + -v, --verbose + Be verbose, includes emitting access logs - -c, --color-scheme <COLOR_SCHEME> - Default color scheme + --index <INDEX> + The name of a directory index file to serve, like "index.html" - [default: squirrel] - [possible values: squirrel, archlinux, zenburn, monokai] + Normally, when miniserve serves a directory, it creates a listing for that directory. However, if a directory contains this + file, miniserve will serve that file instead. - -d, --color-scheme-dark <COLOR_SCHEME_DARK> - Default color scheme + --spa + Activate SPA (Single Page Application) mode - [default: archlinux] - [possible values: squirrel, archlinux, zenburn, monokai] + This will cause the file given by --index to be served for all non-existing file paths. In effect, this will serve the index + file whenever a 404 would otherwise occur in order to allow the SPA router to handle the request instead. - -D, --dirs-first - List directories first + -p, --port <PORT> + Port to use - -F, --hide-version-footer - Hide version footer + [default: 8080] - -g, --enable-tar-gz - Enable gz-compressed tar archive generation + -i, --interfaces <INTERFACES>... + Interface to listen on - -h, --help - Print help information + -a, --auth <AUTH>... + Set authentication. Currently supported formats: username:password, username:sha256:hash, username:sha512:hash (e.g. joe:123, + joe:sha256:a665a45920422f9d417e4867efdc4fb8a04a1f3fff1fa07e998e86f7f7a27ae3) - -H, --hidden - Show hidden files + --route-prefix <ROUTE_PREFIX> + Use a specific route prefix - --header <HEADER> - Set custom header for responses + --random-route + Generate a random 6-hexdigit route - --hide-theme-selector - Hide theme selector + -P, --no-symlinks + Hide symlinks in listing and prevent them from being followed - -i, --interfaces <INTERFACES> - Interface to listen on + -H, --hidden + Show hidden files - --index <index_file> - The name of a directory index file to serve, like "index.html" + -c, --color-scheme <COLOR_SCHEME> + Default color scheme - Normally, when miniserve serves a directory, it creates a listing for that directory. - However, if a directory contains this file, miniserve will serve that file instead. + [default: squirrel] + [possible values: squirrel, archlinux, zenburn, monokai] - -l, --show-symlink-info - Visualize symlinks in directory listing + -d, --color-scheme-dark <COLOR_SCHEME_DARK> + Default color scheme - -m, --media-type <MEDIA_TYPE> - Specify uploadable media types + [default: archlinux] + [possible values: squirrel, archlinux, zenburn, monokai] - [possible values: image, audio, video] + -q, --qrcode + Enable QR code display - -M, --raw-media-type <MEDIA_TYPE_RAW> - Directly specify the uploadable media type expression + -u, --upload-files [<ALLOWED_UPLOAD_DIR>] + Enable file uploading (and optionally specify for which directory) - -o, --overwrite-files - Enable overriding existing files during file upload + -U, --mkdir + Enable creating directories - -p, --port <PORT> - Port to use + -m, --media-type <MEDIA_TYPE> + Specify uploadable media types - [default: 8080] + [possible values: image, audio, video] - -P, --no-symlinks - Hide symlinks in listing and prevent them from being followed + -M, --raw-media-type <MEDIA_TYPE_RAW> + Directly specify the uploadable media type expression - --print-completions <shell> - Generate completion file for a shell + -o, --overwrite-files + Enable overriding existing files during file upload - [possible values: bash, elvish, fish, powershell, zsh] + -r, --enable-tar + Enable uncompressed tar archive generation - --print-manpage - Generate man page + -g, --enable-tar-gz + Enable gz-compressed tar archive generation - -q, --qrcode - Enable QR code display + -z, --enable-zip + Enable zip archive generation - -r, --enable-tar - Enable uncompressed tar archive generation + WARNING: Zipping large directories can result in out-of-memory exception because zip generation is done in memory and cannot + be sent on the fly - --random-route - Generate a random 6-hexdigit route + -D, --dirs-first + List directories first - --readme - Enable README.md rendering in directories + -t, --title <TITLE> + Shown instead of host in page title and heading - --route-prefix <ROUTE_PREFIX> - Use a specific route prefix + --header <HEADER>... + Set custom header for responses - --spa - Activate SPA (Single Page Application) mode + -l, --show-symlink-info + Visualize symlinks in directory listing - This will cause the file given by --index to be served for all non-existing file paths. In - effect, this will serve the index file whenever a 404 would otherwise occur in order to allow the - SPA router to handle the request instead. + -F, --hide-version-footer + Hide version footer - -t, --title <TITLE> - Shown instead of host in page title and heading + --hide-theme-selector + Hide theme selector - --tls-cert <TLS_CERT> - TLS certificate to use + -W, --show-wget-footer + If enabled, display a wget command to recursively download the current directory - --tls-key <TLS_KEY> - TLS private key to use + --print-completions <shell> + Generate completion file for a shell - -u, --upload-files [<ALLOWED_UPLOAD_DIR>...] - Enable file uploading (and optionally specify for which directory) + [possible values: bash, elvish, fish, powershell, zsh] - -U, --mkdir - Enable creating directories + --print-manpage + Generate man page - -v, --verbose - Be verbose, includes emitting access logs + --tls-cert <TLS_CERT> + TLS certificate to use - -V, --version - Print version information + --tls-key <TLS_KEY> + TLS private key to use - -W, --show-wget-footer - If enabled, display a wget command to recursively download the current directory + --readme + Enable README.md rendering in directories - -z, --enable-zip - Enable zip archive generation - - WARNING: Zipping large directories can result in out-of-memory exception because zip generation - is done in memory and cannot be sent on the fly + -h, --help + Print help information (use `-h` for a summary) + + -V, --version + Print version information ## How to install diff --git a/src/args.rs b/src/args.rs index 36e2cf2..7e65d3f 100644 --- a/src/args.rs +++ b/src/args.rs @@ -17,21 +17,21 @@ pub enum MediaType { } #[derive(Parser)] -#[clap(name = "miniserve", author, about, version)] +#[command(name = "miniserve", author, about, version)] pub struct CliArgs { /// Be verbose, includes emitting access logs - #[clap(short = 'v', long = "verbose")] + #[arg(short = 'v', long = "verbose")] pub verbose: bool, /// Which path to serve - #[clap(name = "PATH", value_hint = ValueHint::AnyPath)] + #[arg(value_hint = ValueHint::AnyPath)] pub path: Option<PathBuf>, /// The name of a directory index file to serve, like "index.html" /// /// Normally, when miniserve serves a directory, it creates a listing for that directory. /// However, if a directory contains this file, miniserve will serve that file instead. - #[clap(long, name = "index_file", value_hint = ValueHint::FilePath)] + #[arg(long, value_hint = ValueHint::FilePath)] pub index: Option<PathBuf>, /// Activate SPA (Single Page Application) mode @@ -39,15 +39,15 @@ pub struct CliArgs { /// This will cause the file given by --index to be served for all non-existing file paths. In /// effect, this will serve the index file whenever a 404 would otherwise occur in order to /// allow the SPA router to handle the request instead. - #[clap(long, requires = "index_file")] + #[arg(long, requires = "index")] pub spa: bool, /// Port to use - #[clap(short = 'p', long = "port", default_value = "8080")] + #[arg(short = 'p', long = "port", default_value = "8080")] pub port: u16, /// Interface to listen on - #[clap( + #[arg( short = 'i', long = "interfaces", value_parser(parse_interface), @@ -58,7 +58,7 @@ pub struct CliArgs { /// Set authentication. Currently supported formats: /// username:password, username:sha256:hash, username:sha512:hash /// (e.g. joe:123, joe:sha256:a665a45920422f9d417e4867efdc4fb8a04a1f3fff1fa07e998e86f7f7a27ae3) - #[clap( + #[arg( short = 'a', long = "auth", value_parser(parse_auth), @@ -67,23 +67,23 @@ pub struct CliArgs { pub auth: Vec<auth::RequiredAuth>, /// Use a specific route prefix - #[clap(long = "route-prefix")] + #[arg(long = "route-prefix")] pub route_prefix: Option<String>, /// Generate a random 6-hexdigit route - #[clap(long = "random-route", conflicts_with("route_prefix"))] + #[arg(long = "random-route", conflicts_with("route_prefix"))] pub random_route: bool, /// Hide symlinks in listing and prevent them from being followed - #[clap(short = 'P', long = "no-symlinks")] + #[arg(short = 'P', long = "no-symlinks")] pub no_symlinks: bool, /// Show hidden files - #[clap(short = 'H', long = "hidden")] + #[arg(short = 'H', long = "hidden")] pub hidden: bool, /// Default color scheme - #[clap( + #[arg( short = 'c', long = "color-scheme", default_value = "squirrel", @@ -92,7 +92,7 @@ pub struct CliArgs { pub color_scheme: ThemeSlug, /// Default color scheme - #[clap( + #[arg( short = 'd', long = "color-scheme-dark", default_value = "archlinux", @@ -101,23 +101,23 @@ pub struct CliArgs { pub color_scheme_dark: ThemeSlug, /// Enable QR code display - #[clap(short = 'q', long = "qrcode")] + #[arg(short = 'q', long = "qrcode")] pub qrcode: bool, /// Enable file uploading (and optionally specify for which directory) - #[clap(short = 'u', long = "upload-files", value_hint = ValueHint::FilePath, num_args(0..=1), value_delimiter(','))] + #[arg(short = 'u', long = "upload-files", value_hint = ValueHint::FilePath, num_args(0..=1), value_delimiter(','))] pub allowed_upload_dir: Option<Vec<PathBuf>>, /// Enable creating directories - #[clap(short = 'U', long = "mkdir", requires = "allowed_upload_dir")] + #[arg(short = 'U', long = "mkdir", requires = "allowed_upload_dir")] pub mkdir_enabled: bool, /// Specify uploadable media types - #[clap(short = 'm', long = "media-type", requires = "allowed_upload_dir")] + #[arg(short = 'm', long = "media-type", requires = "allowed_upload_dir")] pub media_type: Option<Vec<MediaType>>, /// Directly specify the uploadable media type expression - #[clap( + #[arg( short = 'M', long = "raw-media-type", requires = "allowed_upload_dir", @@ -126,77 +126,76 @@ pub struct CliArgs { pub media_type_raw: Option<String>, /// Enable overriding existing files during file upload - #[clap(short = 'o', long = "overwrite-files")] + #[arg(short = 'o', long = "overwrite-files")] pub overwrite_files: bool, /// Enable uncompressed tar archive generation - #[clap(short = 'r', long = "enable-tar")] + #[arg(short = 'r', long = "enable-tar")] pub enable_tar: bool, /// Enable gz-compressed tar archive generation - #[clap(short = 'g', long = "enable-tar-gz")] + #[arg(short = 'g', long = "enable-tar-gz")] pub enable_tar_gz: bool, /// Enable zip archive generation /// /// WARNING: Zipping large directories can result in out-of-memory exception /// because zip generation is done in memory and cannot be sent on the fly - #[clap(short = 'z', long = "enable-zip")] + #[arg(short = 'z', long = "enable-zip")] pub enable_zip: bool, /// List directories first - #[clap(short = 'D', long = "dirs-first")] + #[arg(short = 'D', long = "dirs-first")] pub dirs_first: bool, /// Shown instead of host in page title and heading - #[clap(short = 't', long = "title")] + #[arg(short = 't', long = "title")] pub title: Option<String>, /// Set custom header for responses - #[clap( + #[arg( long = "header", value_parser(parse_header), num_args(1..), - number_of_values = 1 )] pub header: Vec<HeaderMap>, /// Visualize symlinks in directory listing - #[clap(short = 'l', long = "show-symlink-info")] + #[arg(short = 'l', long = "show-symlink-info")] pub show_symlink_info: bool, /// Hide version footer - #[clap(short = 'F', long = "hide-version-footer")] + #[arg(short = 'F', long = "hide-version-footer")] pub hide_version_footer: bool, /// Hide theme selector - #[clap(long = "hide-theme-selector")] + #[arg(long = "hide-theme-selector")] pub hide_theme_selector: bool, /// If enabled, display a wget command to recursively download the current directory - #[clap(short = 'W', long = "show-wget-footer")] + #[arg(short = 'W', long = "show-wget-footer")] pub show_wget_footer: bool, /// Generate completion file for a shell - #[clap(long = "print-completions", value_name = "shell")] + #[arg(long = "print-completions", value_name = "shell")] pub print_completions: Option<Shell>, /// Generate man page - #[clap(long = "print-manpage")] + #[arg(long = "print-manpage")] pub print_manpage: bool, /// TLS certificate to use #[cfg(feature = "tls")] - #[clap(long = "tls-cert", requires = "tls_key", value_hint = ValueHint::FilePath)] + #[arg(long = "tls-cert", requires = "tls_key", value_hint = ValueHint::FilePath)] pub tls_cert: Option<PathBuf>, /// TLS private key to use #[cfg(feature = "tls")] - #[clap(long = "tls-key", requires = "tls_cert", value_hint = ValueHint::FilePath)] + #[arg(long = "tls-key", requires = "tls_cert", value_hint = ValueHint::FilePath)] pub tls_key: Option<PathBuf>, /// Enable README.md rendering in directories - #[clap(long)] + #[arg(long)] pub readme: bool, } |