fix: allow args before/after command
This commit is contained in:
@@ -67,6 +67,5 @@ docker-run docker run
|
|||||||
- [x] X-Proxy
|
- [x] X-Proxy
|
||||||
- [x] detect root certificate change and update server
|
- [x] detect root certificate change and update server
|
||||||
- [x] detect tokens change and update token_manager
|
- [x] detect tokens change and update token_manager
|
||||||
- [ ] allow args before/after command
|
|
||||||
- [x] proper doc
|
- [x] proper doc
|
||||||
|
|
||||||
|
|||||||
@@ -49,10 +49,8 @@ See [Docker](#docker) for a quick deployable server.
|
|||||||
<summary>Full CLI Help</summary>
|
<summary>Full CLI Help</summary>
|
||||||
|
|
||||||
```txt
|
```txt
|
||||||
usage: stapler [-h] [--debug | --no-debug] [-d DATA_DIR] [--certificates | --no-certificates] [--certbot | --no-certbot]
|
usage: stapler [-h] [--debug | --no-debug] [-d DATA_DIR] [--certificates | --no-certificates] [--self-signed-path SELF_SIGNED_PATH] [--certbot | --no-certbot] [--certbot-conf CERTBOT_CONF] [--certbot-www CERTBOT_WWW] [--host HOST]
|
||||||
[--self-signed-path SELF_SIGNED_PATH] [--certbot-conf CERTBOT_CONF] [--certbot-www CERTBOT_WWW]
|
[--http-port HTTP_PORT] [--https-port HTTPS_PORT] [--https | --no-https] [-t TOKEN_SALT] [--max-size-bytes MAX_SIZE] [-b BIND]
|
||||||
[--host HOST] [--http-port HTTP_PORT] [--https-port HTTPS_PORT] [--https | --no-https] [-t TOKEN_SALT]
|
|
||||||
[--max-size-bytes MAX_SIZE] [-b BIND]
|
|
||||||
COMMAND ...
|
COMMAND ...
|
||||||
|
|
||||||
Static pages as simple as a gzip file
|
Static pages as simple as a gzip file
|
||||||
@@ -70,10 +68,10 @@ options:
|
|||||||
directory where pages are/will be stored (default: ./data)
|
directory where pages are/will be stored (default: ./data)
|
||||||
--certificates, --no-certificates
|
--certificates, --no-certificates
|
||||||
Handle certificates (default: true)
|
Handle certificates (default: true)
|
||||||
--certbot, --no-certbot
|
|
||||||
Use Certbot (default: true)
|
|
||||||
--self-signed-path SELF_SIGNED_PATH
|
--self-signed-path SELF_SIGNED_PATH
|
||||||
Self-signed certificates dir (default: ./data/.certificates)
|
Self-signed certificates dir (default: ./data/.certificates)
|
||||||
|
--certbot, --no-certbot
|
||||||
|
Use Certbot (default: true)
|
||||||
--certbot-conf CERTBOT_CONF
|
--certbot-conf CERTBOT_CONF
|
||||||
Certbot config dir (default: /etc/letsencrypt)
|
Certbot config dir (default: /etc/letsencrypt)
|
||||||
--certbot-www CERTBOT_WWW
|
--certbot-www CERTBOT_WWW
|
||||||
|
|||||||
+25
-9
@@ -75,6 +75,22 @@ def __add_arg_int(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def __add_arg_bool(
|
||||||
|
parser: argparse.ArgumentParser,
|
||||||
|
*flags: str,
|
||||||
|
default: bool,
|
||||||
|
help_txt: str,
|
||||||
|
dest: str | None = None,
|
||||||
|
) -> None:
|
||||||
|
parser.add_argument(
|
||||||
|
*flags,
|
||||||
|
action=argparse.BooleanOptionalAction,
|
||||||
|
help=f"{help_txt} (default: {str(default).lower()})",
|
||||||
|
default=default,
|
||||||
|
dest=dest,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def parse_parameters(args: typing.Sequence[str]) -> Parameters:
|
def parse_parameters(args: typing.Sequence[str]) -> Parameters:
|
||||||
default_values = Parameters()
|
default_values = Parameters()
|
||||||
parser = argparse.ArgumentParser(
|
parser = argparse.ArgumentParser(
|
||||||
@@ -94,11 +110,11 @@ def parse_parameters(args: typing.Sequence[str]) -> Parameters:
|
|||||||
default=default_values.data_dir,
|
default=default_values.data_dir,
|
||||||
help_txt="directory where pages are/will be stored",
|
help_txt="directory where pages are/will be stored",
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
__add_arg_bool(
|
||||||
|
parser,
|
||||||
"--certificates",
|
"--certificates",
|
||||||
action=argparse.BooleanOptionalAction,
|
|
||||||
help="Handle certificates (default: true)",
|
|
||||||
default=default_values.with_certificates,
|
default=default_values.with_certificates,
|
||||||
|
help_txt="Handle certificates",
|
||||||
dest="with_certificates",
|
dest="with_certificates",
|
||||||
)
|
)
|
||||||
__add_arg_str(
|
__add_arg_str(
|
||||||
@@ -108,11 +124,11 @@ def parse_parameters(args: typing.Sequence[str]) -> Parameters:
|
|||||||
default=default_values.self_signed_path,
|
default=default_values.self_signed_path,
|
||||||
help_txt="Self-signed certificates dir",
|
help_txt="Self-signed certificates dir",
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
__add_arg_bool(
|
||||||
|
parser,
|
||||||
"--certbot",
|
"--certbot",
|
||||||
action=argparse.BooleanOptionalAction,
|
|
||||||
help="Use Certbot (default: true)",
|
|
||||||
default=default_values.with_certbot,
|
default=default_values.with_certbot,
|
||||||
|
help_txt="Use Certbot",
|
||||||
dest="with_certbot",
|
dest="with_certbot",
|
||||||
)
|
)
|
||||||
__add_arg_str(
|
__add_arg_str(
|
||||||
@@ -150,11 +166,11 @@ def parse_parameters(args: typing.Sequence[str]) -> Parameters:
|
|||||||
default=default_values.https_port,
|
default=default_values.https_port,
|
||||||
help_txt="server https port",
|
help_txt="server https port",
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
__add_arg_bool(
|
||||||
|
parser,
|
||||||
"--https",
|
"--https",
|
||||||
action=argparse.BooleanOptionalAction,
|
|
||||||
help="Use https (implies --certificates) (default: true)",
|
|
||||||
default=default_values.https,
|
default=default_values.https,
|
||||||
|
help_txt="Use https (implies --certificates)",
|
||||||
)
|
)
|
||||||
__add_arg_str(
|
__add_arg_str(
|
||||||
parser,
|
parser,
|
||||||
|
|||||||
Reference in New Issue
Block a user