From 592fe6a08761fa42f2991d02ee624d60b39dc258 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mislav=20Marohni=C4=87?= Date: Tue, 11 Jul 2023 18:54:38 +0200 Subject: [PATCH] help: have `--usage` always print a usage line --- libexec/rbenv-help | 6 +++++- test/help.bats | 12 ++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/libexec/rbenv-help b/libexec/rbenv-help index ef041525..84d6e464 100755 --- a/libexec/rbenv-help +++ b/libexec/rbenv-help @@ -144,7 +144,11 @@ print_usage() { local command="$1" local summary usage help eval "$(documentation_for "$command")" - [ -z "$usage" ] || echo "$usage" + if [ -n "$usage" ]; then + echo "$usage" + else + echo "Usage: rbenv ${command}" + fi } unset usage diff --git a/test/help.bats b/test/help.bats index 256549ee..3102136d 100644 --- a/test/help.bats +++ b/test/help.bats @@ -71,6 +71,18 @@ SH assert_success "Usage: rbenv hello " } +@test "empty usage section" { + mkdir -p "${RBENV_TEST_DIR}/bin" + cat > "${RBENV_TEST_DIR}/bin/rbenv-hello" < "${RBENV_TEST_DIR}/bin/rbenv-hello" <