chore: hide env keys from help text (#176)
This commit is contained in:
parent
b7c5119c2e
commit
c6dcaf95d4
2 changed files with 49 additions and 23 deletions
50
README.md
50
README.md
|
@ -51,30 +51,30 @@ Dufs is a distinctive utility file server - https://github.com/sigoden/dufs
|
||||||
Usage: dufs [OPTIONS] [root]
|
Usage: dufs [OPTIONS] [root]
|
||||||
|
|
||||||
Arguments:
|
Arguments:
|
||||||
[root] Specific path to serve [env: DUFS_ROOT=] [default: .]
|
[root] Specific path to serve [default: .]
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
-b, --bind <addrs> Specify bind address or unix socket [env: DUFS_BIND=]
|
-b, --bind <addrs> Specify bind address or unix socket
|
||||||
-p, --port <port> Specify port to listen on [env: DUFS_PORT=] [default: 5000]
|
-p, --port <port> Specify port to listen on [default: 5000]
|
||||||
--path-prefix <path> Specify a path prefix [env: DUFS_PATH_PREFIX=]
|
--path-prefix <path> Specify a path prefix
|
||||||
--hidden <value> Hide paths from directory listings, separated by `,` [env: DUFS_HIDDEN=]
|
--hidden <value> Hide paths from directory listings, separated by `,`
|
||||||
-a, --auth <rules> Add auth for path [env: DUFS_AUTH=]
|
-a, --auth <rules> Add auth for path
|
||||||
--auth-method <value> Select auth method [env: DUFS_AUTH_METHOD=] [default: digest] [possible values: basic, digest]
|
--auth-method <value> Select auth method [default: digest] [possible values: basic, digest]
|
||||||
-A, --allow-all Allow all operations [env: DUFS_ALLOW_ALL=]
|
-A, --allow-all Allow all operations
|
||||||
--allow-upload Allow upload files/folders [env: DUFS_ALLOW_UPLOAD=]
|
--allow-upload Allow upload files/folders
|
||||||
--allow-delete Allow delete files/folders [env: DUFS_ALLOW_DELETE=]
|
--allow-delete Allow delete files/folders
|
||||||
--allow-search Allow search files/folders [env: DUFS_ALLOW_SEARCH=]
|
--allow-search Allow search files/folders
|
||||||
--allow-symlink Allow symlink to files/folders outside root directory [env: DUFS_ALLOW_SYMLINK=]
|
--allow-symlink Allow symlink to files/folders outside root directory
|
||||||
--allow-archive Allow zip archive generation [env: DUFS_ALLOW_ARCHIVE=]
|
--allow-archive Allow zip archive generation
|
||||||
--enable-cors Enable CORS, sets `Access-Control-Allow-Origin: *` [env: DUFS_ENABLE_CORS=]
|
--enable-cors Enable CORS, sets `Access-Control-Allow-Origin: *`
|
||||||
--render-index Serve index.html when requesting a directory, returns 404 if not found index.html [env: DUFS_RENDER_INDEX=]
|
--render-index Serve index.html when requesting a directory, returns 404 if not found index.html
|
||||||
--render-try-index Serve index.html when requesting a directory, returns directory listing if not found index.html [env: DUFS_RENDER_TRY_INDEX=]
|
--render-try-index Serve index.html when requesting a directory, returns directory listing if not found index.html
|
||||||
--render-spa Serve SPA(Single Page Application) [env: DUFS_RENDER_SPA=]
|
--render-spa Serve SPA(Single Page Application)
|
||||||
--assets <path> Use custom assets to override builtin assets [env: DUFS_ASSETS=]
|
--assets <path> Use custom assets to override builtin assets
|
||||||
--tls-cert <path> Path to an SSL/TLS certificate to serve with HTTPS [env: DUFS_TLS_CERT=]
|
--tls-cert <path> Path to an SSL/TLS certificate to serve with HTTPS
|
||||||
--tls-key <path> Path to the SSL/TLS certificate's private key [env: DUFS_TLS_KEY=]
|
--tls-key <path> Path to the SSL/TLS certificate's private key
|
||||||
--log-format <format> Customize http log format [env: DUFS_LOG_FORMAT=]
|
--log-format <format> Customize http log format
|
||||||
--completions <shell> Print shell completion script for <shell> [env: DUFS_COMPLETIONS=] [possible values: bash, elvish, fish, powershell, zsh]
|
--completions <shell> Print shell completion script for <shell> [possible values: bash, elvish, fish, powershell, zsh]
|
||||||
-h, --help Print help information
|
-h, --help Print help information
|
||||||
-V, --version Print version information
|
-V, --version Print version information
|
||||||
```
|
```
|
||||||
|
@ -274,6 +274,12 @@ dufs --log-format '$remote_addr $remote_user "$request" $status' -a /@admin:admi
|
||||||
2022-08-06T07:04:37+08:00 INFO - 127.0.0.1 admin "GET /" 200
|
2022-08-06T07:04:37+08:00 INFO - 127.0.0.1 admin "GET /" 200
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Environment variables
|
||||||
|
|
||||||
|
All options can be set using environment variables prefixed with `DUFS_`.
|
||||||
|
|
||||||
|
`dufs --port 8080 --allow-all` is equal to `DUFS_PORT=8080 DUFS_ALLOW_ALL=true dufs`.
|
||||||
|
|
||||||
### Customize UI
|
### Customize UI
|
||||||
|
|
||||||
Dufs allows users to customize the UI with your own assets.
|
Dufs allows users to customize the UI with your own assets.
|
||||||
|
|
22
src/args.rs
22
src/args.rs
|
@ -27,6 +27,7 @@ pub fn build_cli() -> Command {
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new("root")
|
Arg::new("root")
|
||||||
.env("DUFS_ROOT")
|
.env("DUFS_ROOT")
|
||||||
|
.hide_env(true)
|
||||||
.default_value(".")
|
.default_value(".")
|
||||||
.value_parser(value_parser!(PathBuf))
|
.value_parser(value_parser!(PathBuf))
|
||||||
.help("Specific path to serve"),
|
.help("Specific path to serve"),
|
||||||
|
@ -34,6 +35,7 @@ pub fn build_cli() -> Command {
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new("bind")
|
Arg::new("bind")
|
||||||
.env("DUFS_BIND")
|
.env("DUFS_BIND")
|
||||||
|
.hide_env(true)
|
||||||
.short('b')
|
.short('b')
|
||||||
.long("bind")
|
.long("bind")
|
||||||
.help("Specify bind address or unix socket")
|
.help("Specify bind address or unix socket")
|
||||||
|
@ -44,6 +46,7 @@ pub fn build_cli() -> Command {
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new("port")
|
Arg::new("port")
|
||||||
.env("DUFS_PORT")
|
.env("DUFS_PORT")
|
||||||
|
.hide_env(true)
|
||||||
.short('p')
|
.short('p')
|
||||||
.long("port")
|
.long("port")
|
||||||
.default_value("5000")
|
.default_value("5000")
|
||||||
|
@ -54,6 +57,7 @@ pub fn build_cli() -> Command {
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new("path-prefix")
|
Arg::new("path-prefix")
|
||||||
.env("DUFS_PATH_PREFIX")
|
.env("DUFS_PATH_PREFIX")
|
||||||
|
.hide_env(true)
|
||||||
.long("path-prefix")
|
.long("path-prefix")
|
||||||
.value_name("path")
|
.value_name("path")
|
||||||
.help("Specify a path prefix"),
|
.help("Specify a path prefix"),
|
||||||
|
@ -61,6 +65,7 @@ pub fn build_cli() -> Command {
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new("hidden")
|
Arg::new("hidden")
|
||||||
.env("DUFS_HIDDEN")
|
.env("DUFS_HIDDEN")
|
||||||
|
.hide_env(true)
|
||||||
.long("hidden")
|
.long("hidden")
|
||||||
.help("Hide paths from directory listings, separated by `,`")
|
.help("Hide paths from directory listings, separated by `,`")
|
||||||
.value_name("value"),
|
.value_name("value"),
|
||||||
|
@ -68,6 +73,7 @@ pub fn build_cli() -> Command {
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new("auth")
|
Arg::new("auth")
|
||||||
.env("DUFS_AUTH")
|
.env("DUFS_AUTH")
|
||||||
|
.hide_env(true)
|
||||||
.short('a')
|
.short('a')
|
||||||
.long("auth")
|
.long("auth")
|
||||||
.help("Add auth for path")
|
.help("Add auth for path")
|
||||||
|
@ -78,6 +84,7 @@ pub fn build_cli() -> Command {
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new("auth-method")
|
Arg::new("auth-method")
|
||||||
.env("DUFS_AUTH_METHOD")
|
.env("DUFS_AUTH_METHOD")
|
||||||
|
.hide_env(true)
|
||||||
.long("auth-method")
|
.long("auth-method")
|
||||||
.help("Select auth method")
|
.help("Select auth method")
|
||||||
.value_parser(PossibleValuesParser::new(["basic", "digest"]))
|
.value_parser(PossibleValuesParser::new(["basic", "digest"]))
|
||||||
|
@ -87,6 +94,7 @@ pub fn build_cli() -> Command {
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new("allow-all")
|
Arg::new("allow-all")
|
||||||
.env("DUFS_ALLOW_ALL")
|
.env("DUFS_ALLOW_ALL")
|
||||||
|
.hide_env(true)
|
||||||
.short('A')
|
.short('A')
|
||||||
.long("allow-all")
|
.long("allow-all")
|
||||||
.action(ArgAction::SetTrue)
|
.action(ArgAction::SetTrue)
|
||||||
|
@ -95,6 +103,7 @@ pub fn build_cli() -> Command {
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new("allow-upload")
|
Arg::new("allow-upload")
|
||||||
.env("DUFS_ALLOW_UPLOAD")
|
.env("DUFS_ALLOW_UPLOAD")
|
||||||
|
.hide_env(true)
|
||||||
.long("allow-upload")
|
.long("allow-upload")
|
||||||
.action(ArgAction::SetTrue)
|
.action(ArgAction::SetTrue)
|
||||||
.help("Allow upload files/folders"),
|
.help("Allow upload files/folders"),
|
||||||
|
@ -102,6 +111,7 @@ pub fn build_cli() -> Command {
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new("allow-delete")
|
Arg::new("allow-delete")
|
||||||
.env("DUFS_ALLOW_DELETE")
|
.env("DUFS_ALLOW_DELETE")
|
||||||
|
.hide_env(true)
|
||||||
.long("allow-delete")
|
.long("allow-delete")
|
||||||
.action(ArgAction::SetTrue)
|
.action(ArgAction::SetTrue)
|
||||||
.help("Allow delete files/folders"),
|
.help("Allow delete files/folders"),
|
||||||
|
@ -109,6 +119,7 @@ pub fn build_cli() -> Command {
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new("allow-search")
|
Arg::new("allow-search")
|
||||||
.env("DUFS_ALLOW_SEARCH")
|
.env("DUFS_ALLOW_SEARCH")
|
||||||
|
.hide_env(true)
|
||||||
.long("allow-search")
|
.long("allow-search")
|
||||||
.action(ArgAction::SetTrue)
|
.action(ArgAction::SetTrue)
|
||||||
.help("Allow search files/folders"),
|
.help("Allow search files/folders"),
|
||||||
|
@ -116,6 +127,7 @@ pub fn build_cli() -> Command {
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new("allow-symlink")
|
Arg::new("allow-symlink")
|
||||||
.env("DUFS_ALLOW_SYMLINK")
|
.env("DUFS_ALLOW_SYMLINK")
|
||||||
|
.hide_env(true)
|
||||||
.long("allow-symlink")
|
.long("allow-symlink")
|
||||||
.action(ArgAction::SetTrue)
|
.action(ArgAction::SetTrue)
|
||||||
.help("Allow symlink to files/folders outside root directory"),
|
.help("Allow symlink to files/folders outside root directory"),
|
||||||
|
@ -123,6 +135,7 @@ pub fn build_cli() -> Command {
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new("allow-archive")
|
Arg::new("allow-archive")
|
||||||
.env("DUFS_ALLOW_ARCHIVE")
|
.env("DUFS_ALLOW_ARCHIVE")
|
||||||
|
.hide_env(true)
|
||||||
.long("allow-archive")
|
.long("allow-archive")
|
||||||
.action(ArgAction::SetTrue)
|
.action(ArgAction::SetTrue)
|
||||||
.help("Allow zip archive generation"),
|
.help("Allow zip archive generation"),
|
||||||
|
@ -130,6 +143,7 @@ pub fn build_cli() -> Command {
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new("enable-cors")
|
Arg::new("enable-cors")
|
||||||
.env("DUFS_ENABLE_CORS")
|
.env("DUFS_ENABLE_CORS")
|
||||||
|
.hide_env(true)
|
||||||
.long("enable-cors")
|
.long("enable-cors")
|
||||||
.action(ArgAction::SetTrue)
|
.action(ArgAction::SetTrue)
|
||||||
.help("Enable CORS, sets `Access-Control-Allow-Origin: *`"),
|
.help("Enable CORS, sets `Access-Control-Allow-Origin: *`"),
|
||||||
|
@ -137,6 +151,7 @@ pub fn build_cli() -> Command {
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new("render-index")
|
Arg::new("render-index")
|
||||||
.env("DUFS_RENDER_INDEX")
|
.env("DUFS_RENDER_INDEX")
|
||||||
|
.hide_env(true)
|
||||||
.long("render-index")
|
.long("render-index")
|
||||||
.action(ArgAction::SetTrue)
|
.action(ArgAction::SetTrue)
|
||||||
.help("Serve index.html when requesting a directory, returns 404 if not found index.html"),
|
.help("Serve index.html when requesting a directory, returns 404 if not found index.html"),
|
||||||
|
@ -144,6 +159,7 @@ pub fn build_cli() -> Command {
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new("render-try-index")
|
Arg::new("render-try-index")
|
||||||
.env("DUFS_RENDER_TRY_INDEX")
|
.env("DUFS_RENDER_TRY_INDEX")
|
||||||
|
.hide_env(true)
|
||||||
.long("render-try-index")
|
.long("render-try-index")
|
||||||
.action(ArgAction::SetTrue)
|
.action(ArgAction::SetTrue)
|
||||||
.help("Serve index.html when requesting a directory, returns directory listing if not found index.html"),
|
.help("Serve index.html when requesting a directory, returns directory listing if not found index.html"),
|
||||||
|
@ -151,6 +167,7 @@ pub fn build_cli() -> Command {
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new("render-spa")
|
Arg::new("render-spa")
|
||||||
.env("DUFS_RENDER_SPA")
|
.env("DUFS_RENDER_SPA")
|
||||||
|
.hide_env(true)
|
||||||
.long("render-spa")
|
.long("render-spa")
|
||||||
.action(ArgAction::SetTrue)
|
.action(ArgAction::SetTrue)
|
||||||
.help("Serve SPA(Single Page Application)"),
|
.help("Serve SPA(Single Page Application)"),
|
||||||
|
@ -158,6 +175,7 @@ pub fn build_cli() -> Command {
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new("assets")
|
Arg::new("assets")
|
||||||
.env("DUFS_ASSETS")
|
.env("DUFS_ASSETS")
|
||||||
|
.hide_env(true)
|
||||||
.long("assets")
|
.long("assets")
|
||||||
.help("Use custom assets to override builtin assets")
|
.help("Use custom assets to override builtin assets")
|
||||||
.value_parser(value_parser!(PathBuf))
|
.value_parser(value_parser!(PathBuf))
|
||||||
|
@ -169,6 +187,7 @@ pub fn build_cli() -> Command {
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new("tls-cert")
|
Arg::new("tls-cert")
|
||||||
.env("DUFS_TLS_CERT")
|
.env("DUFS_TLS_CERT")
|
||||||
|
.hide_env(true)
|
||||||
.long("tls-cert")
|
.long("tls-cert")
|
||||||
.value_name("path")
|
.value_name("path")
|
||||||
.value_parser(value_parser!(PathBuf))
|
.value_parser(value_parser!(PathBuf))
|
||||||
|
@ -177,6 +196,7 @@ pub fn build_cli() -> Command {
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new("tls-key")
|
Arg::new("tls-key")
|
||||||
.env("DUFS_TLS_KEY")
|
.env("DUFS_TLS_KEY")
|
||||||
|
.hide_env(true)
|
||||||
.long("tls-key")
|
.long("tls-key")
|
||||||
.value_name("path")
|
.value_name("path")
|
||||||
.value_parser(value_parser!(PathBuf))
|
.value_parser(value_parser!(PathBuf))
|
||||||
|
@ -186,13 +206,13 @@ pub fn build_cli() -> Command {
|
||||||
app.arg(
|
app.arg(
|
||||||
Arg::new("log-format")
|
Arg::new("log-format")
|
||||||
.env("DUFS_LOG_FORMAT")
|
.env("DUFS_LOG_FORMAT")
|
||||||
|
.hide_env(true)
|
||||||
.long("log-format")
|
.long("log-format")
|
||||||
.value_name("format")
|
.value_name("format")
|
||||||
.help("Customize http log format"),
|
.help("Customize http log format"),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new("completions")
|
Arg::new("completions")
|
||||||
.env("DUFS_COMPLETIONS")
|
|
||||||
.long("completions")
|
.long("completions")
|
||||||
.value_name("shell")
|
.value_name("shell")
|
||||||
.value_parser(value_parser!(Shell))
|
.value_parser(value_parser!(Shell))
|
||||||
|
|
Loading…
Reference in a new issue