diff --git a/CHANGELOG.md b/CHANGELOG.md index 0bde69f..a657d8c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -37,6 +37,9 @@ A major release: automatic Let's Encrypt SSL with multi-DNS-provider support. - `easy proxy create` no longer writes a state file into the install directory. After `npm install -g` that directory is root-owned, so non-root users got `Permission denied` ([#5]). +- `easy --version` and `easy proxy help` now work before the runtime env vars + (`EASY_LETSENCRYPT_DIR`, `EASY_DOMAINS_DIR`) are set — they no longer fail + with `... is not set!`, so a freshly installed CLI can be inspected. - Argument quoting hardened across the `easy` dispatcher and `commands/proxy.sh` (ShellCheck cleanup). diff --git a/easy b/easy index 1a3a5c4..ed49a45 100755 --- a/easy +++ b/easy @@ -34,8 +34,16 @@ function easy_verify_dir { fi } -easy_verify_dir EASY_LETSENCRYPT_DIR "$EASY_LETSENCRYPT_DIR" -easy_verify_dir EASY_DOMAINS_DIR "$EASY_DOMAINS_DIR" +# `easy --version` and `easy proxy help` are informational — they need +# neither EASY_LETSENCRYPT_DIR nor EASY_DOMAINS_DIR. Skip the check for them +# so a freshly installed CLI can be inspected before those env vars are set. +case "$1:$2" in + --version:* | proxy:help) : ;; + *) + easy_verify_dir EASY_LETSENCRYPT_DIR "$EASY_LETSENCRYPT_DIR" + easy_verify_dir EASY_DOMAINS_DIR "$EASY_DOMAINS_DIR" + ;; +esac D="${EASY_DIR}/commands" function __private_easy_usage { diff --git a/test/dispatcher.bats b/test/dispatcher.bats index d583494..607c38d 100644 --- a/test/dispatcher.bats +++ b/test/dispatcher.bats @@ -11,6 +11,13 @@ setup() { easy_setup; } [ "$output" = "2.0.0" ] } +@test "easy --version works without the runtime env vars set" { + unset EASY_LETSENCRYPT_DIR EASY_DOMAINS_DIR + run easy --version + [ "$status" -eq 0 ] + [ "$output" = "2.0.0" ] +} + @test "easy with no command prints usage and fails" { run easy [ "$status" -eq 1 ] diff --git a/test/proxy.bats b/test/proxy.bats index 6c5ea85..9f05ffc 100644 --- a/test/proxy.bats +++ b/test/proxy.bats @@ -18,6 +18,13 @@ setup() { easy_setup; } [[ "$output" == *"easy proxy certbot-ionos "* ]] } +@test "easy proxy help works without the runtime env vars set" { + unset EASY_LETSENCRYPT_DIR EASY_DOMAINS_DIR + run easy proxy help + [ "$status" -eq 0 ] + [[ "$output" == *"easy proxy create"* ]] +} + @test "easy proxy with an unknown subcommand prints usage and fails" { run easy proxy not-a-real-subcommand [ "$status" -eq 1 ]