Skip to content

Commit

Permalink
cmd/status: Change --printExecPath exit code
Browse files Browse the repository at this point in the history
When version management is disabled in the current directory, running
hvm status --printExecPath should (a) print nothing, and (b) return
error code 1.

Closes #28
  • Loading branch information
jmooring committed Sep 20, 2023
1 parent 9569265 commit d756b2e
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 26 deletions.
12 changes: 4 additions & 8 deletions cmd/hvm/alias_scripts/bash.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
# Hugo Version Manager: override path to the hugo executable.
hugo() {
hvm_show_status=true
if [ -f ".hvm" ]; then
if ! hugo_bin=$(hvm status --printExecPath); then
return 1
else
if [ "${hvm_show_status}" == true ]; then
>&2 printf "Hugo version management is enabled in this directory.\\n"
>&2 printf "Run 'hvm status' for details, or 'hvm disable' to disable.\\n\\n"
fi
if hugo_bin=$(hvm status --printExecPath); then
if [ "${hvm_show_status}" == true ]; then
>&2 printf "Hugo version management is enabled in this directory.\\n"
>&2 printf "Run 'hvm status' for details, or 'hvm disable' to disable.\\n\\n"
fi
else
if ! hugo_bin=$(which hugo); then
Expand Down
12 changes: 4 additions & 8 deletions cmd/hvm/alias_scripts/fish.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
# Hugo Version Manager: override path to the hugo executable.
hugo() {
hvm_show_status=true
if [ -f ".hvm" ]; then
if ! hugo_bin=$(hvm status --printExecPath); then
return 1
else
if [ "${hvm_show_status}" == true ]; then
>&2 printf "Hugo version management is enabled in this directory.\\n"
>&2 printf "Run 'hvm status' for details, or 'hvm disable' to disable.\\n\\n"
fi
if hugo_bin=$(hvm status --printExecPath); then
if [ "${hvm_show_status}" == true ]; then
>&2 printf "Hugo version management is enabled in this directory.\\n"
>&2 printf "Run 'hvm status' for details, or 'hvm disable' to disable.\\n\\n"
fi
else
if ! hugo_bin=$(which hugo); then
Expand Down
12 changes: 4 additions & 8 deletions cmd/hvm/alias_scripts/zsh.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
# Hugo Version Manager: override path to the hugo executable.
hugo() {
hvm_show_status=true
if [ -f ".hvm" ]; then
if ! hugo_bin=$(hvm status --printExecPath); then
return 1
else
if [ "${hvm_show_status}" == true ]; then
>&2 printf "Hugo version management is enabled in this directory.\\n"
>&2 printf "Run 'hvm status' for details, or 'hvm disable' to disable.\\n\\n"
fi
if hugo_bin=$(hvm status --printExecPath); then
if [ "${hvm_show_status}" == true ]; then
>&2 printf "Hugo version management is enabled in this directory.\\n"
>&2 printf "Run 'hvm status' for details, or 'hvm disable' to disable.\\n\\n"
fi
else
if ! hugo_bin=$(which hugo); then
Expand Down
3 changes: 1 addition & 2 deletions cmd/hvm/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@ func status() error {

if viper.GetBool("printExecPath") {
if version == "" {
fmt.Println("Version management is disabled in the current directory.")
return nil
os.Exit(1)
} else {
fmt.Println(filepath.Join(App.CacheDirPath, version, getExecName()))
}
Expand Down

0 comments on commit d756b2e

Please sign in to comment.