mirror of
https://github.com/pyenv/pyenv.git
synced 2024-12-03 15:13:38 -05:00
Merge pull request #1515 from rbenv/help-usage
help: have `--usage` always print a usage line
This commit is contained in:
commit
4fec76f267
2 changed files with 17 additions and 1 deletions
|
@ -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
|
||||
|
|
|
@ -71,6 +71,18 @@ SH
|
|||
assert_success "Usage: rbenv hello <world>"
|
||||
}
|
||||
|
||||
@test "empty usage section" {
|
||||
mkdir -p "${RBENV_TEST_DIR}/bin"
|
||||
cat > "${RBENV_TEST_DIR}/bin/rbenv-hello" <<SH
|
||||
#!shebang
|
||||
# Summary: Says "hello" to you, from rbenv
|
||||
echo hello
|
||||
SH
|
||||
|
||||
run rbenv-help --usage hello
|
||||
assert_success "Usage: rbenv hello"
|
||||
}
|
||||
|
||||
@test "multiline usage section" {
|
||||
mkdir -p "${RBENV_TEST_DIR}/bin"
|
||||
cat > "${RBENV_TEST_DIR}/bin/rbenv-hello" <<SH
|
||||
|
|
Loading…
Reference in a new issue