Skip to content

Commit

Permalink
fix noisy app detection on headless environments
Browse files Browse the repository at this point in the history
/close #192
  • Loading branch information
balupton committed Dec 6, 2023
1 parent 337d102 commit 08be7b1
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
4 changes: 2 additions & 2 deletions commands/edit
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ function edit_() (

# grab options
local editors=()
if test "$terminal" = 'yes' -o "$sudo" = 'yes'; then
if test "$terminal" = 'yes'; then
editors=("${TERMINAL_EDITORS[@]}")
else
editors=("${GUI_EDITORS[@]}")
Expand Down Expand Up @@ -159,7 +159,7 @@ function edit_() (

# it exists, use it
break
elif get-app "$command" >/dev/null; then
elif test "$terminal" = 'no' && get-app "$command" >/dev/null; then
# apps require prompts
if test "$prompt" = 'yes'; then
mapfile -t array < <(echo-split ' ' -- "$string")
Expand Down
13 changes: 11 additions & 2 deletions commands/get-app
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,22 @@ function get_app() (
fi
fi
if test "$can_find" = 'no'; then
echo-error 'Install Winget or Scoop to be able to detect applications on WSL'
if test "$quiet" != 'yes'; then
echo-error "Unable to detect application [$name] on WSL. Install Winget or Scoop."
fi
return 6 # ENXIO 6 Device not configured
fi
# wasn't found
return 1
elif is-headless; then
if test "$quiet" != 'yes'; then
echo-style --notice="Skipping detection of application [$name] on headless system." >/dev/stderr
fi
return 1
else
echo-error 'Support for Applications not added yet for this platform.'
if test "$quiet" != 'yes'; then
echo-error "Unable to detect application [$name] on Linux. Submit a PR to support it."
fi
return 19 # ENODEV 19 Operation not supported by device
fi
)
Expand Down
10 changes: 5 additions & 5 deletions commands/git-helper
Original file line number Diff line number Diff line change
Expand Up @@ -466,14 +466,14 @@ function git_helper() (
}

function git_review {
if get-app --quiet 'Gitfox.app'; then
open-app 'Gitfox.app' -- "$@"
elif get-app --quiet 'Tower.app'; then
open-app 'Tower.app' -- "$@"
elif command-exists gf; then
if command-exists gf; then
gf "$@"
elif get-app --quiet 'Gitfox.app'; then
open-app 'Gitfox.app' -- "$@"
elif command-exists tower; then
tower "$@"
elif get-app --quiet 'Tower.app'; then
open-app 'Tower.app' -- "$@"
else
help "No supported git reviewers installed."
fi
Expand Down

0 comments on commit 08be7b1

Please sign in to comment.