refactor: use argparse subparser

This commit is contained in:
2026-04-12 22:59:30 +02:00
parent 1e163f4023
commit 87341d4c25
4 changed files with 99 additions and 62 deletions
+32 -7
View File
@@ -1,20 +1,27 @@
# Stapler
```txt
usage: stapler [-h] [-p PORT] [--host HOST] [-d DATA_DIR] -t TOKEN [--max-size-bytes MAX_SIZE] [-b BIND] [--certbot-conf CERTBOT_CONF] [--certbot-www CERTBOT_WWW]
usage: stapler [-h] [--debug | --no-debug] [-d DATA_DIR] [--certificates | --no-certificates] [--certbot | --no-certbot] [--self-signed-path SELF_SIGNED_PATH] [--certbot-conf CERTBOT_CONF]
[--certbot-www CERTBOT_WWW]
COMMAND ...
Static pages as simple as a gzip file
positional arguments:
COMMAND
run Run Stapler server
options:
-h, --help show this help message and exit
-p, --port PORT server port (default: 8080)
--host HOST server default host (default: localhost)
--debug, --no-debug
-d, --data-dir DATA_DIR
directory where pages are/will be stored (default: ./data)
-t, --token TOKEN secret token for update requests
--max-size-bytes MAX_SIZE
max size of accepted archives (in bytes) (default: 2000000)
-b, --bind BIND server bind address (default: 0.0.0.0)
--certificates, --no-certificates
Handle certificates (default: true)
--certbot, --no-certbot
Use Certbot (default: true)
--self-signed-path SELF_SIGNED_PATH
Self-signed certificates dir (default: ./data/.certificates)
--certbot-conf CERTBOT_CONF
Certbot config dir (default: /etc/letsencrypt)
--certbot-www CERTBOT_WWW
@@ -23,6 +30,24 @@ options:
(Each option can be supplied with equivalent environment variable.)
```
```txt
usage: stapler run [-h] [--host HOST] [-p PORT] [--https | --no-https] -t TOKEN [--max-size-bytes MAX_SIZE] [-b BIND]
Run Stapler server
options:
-h, --help show this help message and exit
--host HOST server default host (default: localhost:8080)
-p, --port PORT server port (default: 8080)
--https, --no-https Use https (implies --certificates) (default: true)
-t, --token TOKEN secret token for update requests
--max-size-bytes MAX_SIZE
max size of accepted archives (in bytes) (default: 2000000)
-b, --bind BIND server bind address (default: 0.0.0.0)
(Each option can be supplied with equivalent environment variable.)
```
## Endpoints
### Create/update page