fix(deps): fix autoloading and Fish 4.x test compatibility
Split _fish_deps_pm.fish into one file per function so Fish can autoload each by name (_fish_deps_detect_pm, _fish_deps_pm_install, _fish_deps_pm_upgrade). A single file with multiple functions only autoloads under the filename, leaving the others unreachable. Replace all `test -a`/`test -o` binary operators with `; and`/`; or` chains throughout _fish_deps_install and _fish_deps_update. Fish 4.x removed support for -a/-o in test, causing the "unexpected argument" errors seen on Debian. Also consolidate paru/yay cases in pm_install and pm_upgrade since both helpers use identical flags.
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
# Copyright (C) 2026 Rootiest
|
||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
# Detect the first available system package manager.
|
||||
function _fish_deps_detect_pm
|
||||
for pm in paru yay pacman apt brew pkg dnf yum
|
||||
if type -q $pm
|
||||
echo $pm
|
||||
return
|
||||
end
|
||||
end
|
||||
echo ""
|
||||
end
|
||||
@@ -21,13 +21,13 @@ function _fish_deps_install
|
||||
set -l method_labels
|
||||
|
||||
# Cargo — only if cargo is present and the tool has a crate
|
||||
if test -n "$cargo_crate" -a (type -q cargo)
|
||||
if test -n "$cargo_crate"; and type -q cargo
|
||||
set -a methods cargo
|
||||
set -a method_labels "cargo ($cargo_crate)"
|
||||
end
|
||||
|
||||
# System PM — only if a PM is detected and the tool is in repos
|
||||
if test -n "$pm_pkg" -a -n "$pm"
|
||||
if test -n "$pm_pkg"; and test -n "$pm"
|
||||
set -a methods pm
|
||||
set -a method_labels "$pm ($pm_pkg)"
|
||||
end
|
||||
@@ -44,7 +44,6 @@ function _fish_deps_install
|
||||
set -a methods special-curl
|
||||
set -a method_labels "curl installer"
|
||||
case paru-build
|
||||
# Only useful on Arch; skip if pacman not present
|
||||
if type -q yay
|
||||
set -a methods special-yay-paru
|
||||
set -a method_labels "yay -S paru"
|
||||
@@ -74,7 +73,7 @@ function _fish_deps_install
|
||||
# Prompt: install this dep?
|
||||
set_color cyan; echo -n "Install $bin? "; set_color normal
|
||||
read -l -P "[Y/n] " _reply
|
||||
if test "$_reply" = n -o "$_reply" = N
|
||||
if test "$_reply" = n; or test "$_reply" = N
|
||||
set i (math $i + 1)
|
||||
continue
|
||||
end
|
||||
@@ -89,7 +88,7 @@ function _fish_deps_install
|
||||
set m (math $m + 1)
|
||||
end
|
||||
read -l -P " Choose [1-"(count $methods)"] (default 1): " _choice
|
||||
if test -n "$_choice" -a "$_choice" -ge 1 -a "$_choice" -le (count $methods) 2>/dev/null
|
||||
if test -n "$_choice"; and test "$_choice" -ge 1; and test "$_choice" -le (count $methods)
|
||||
set chosen_method $methods[$_choice]
|
||||
end
|
||||
end
|
||||
@@ -106,7 +105,6 @@ function _fish_deps_install
|
||||
curl -sL https://raw.githubusercontent.com/jorgebucaran/fisher/main/functions/fisher.fish | source
|
||||
fisher update
|
||||
case special-curl
|
||||
# Currently used for starship
|
||||
if test "$bin" = starship
|
||||
curl -sS https://starship.rs/install.sh | sh
|
||||
end
|
||||
|
||||
@@ -1,69 +0,0 @@
|
||||
# Copyright (C) 2026 Rootiest
|
||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
# Detect the first available system package manager.
|
||||
function _fish_deps_detect_pm
|
||||
for pm in paru yay pacman apt brew pkg dnf yum
|
||||
if type -q $pm
|
||||
echo $pm
|
||||
return
|
||||
end
|
||||
end
|
||||
echo ""
|
||||
end
|
||||
|
||||
# Install a package via the system PM.
|
||||
# Usage: _fish_deps_pm_install <pkg>
|
||||
function _fish_deps_pm_install --argument-names pkg
|
||||
set -l pm (_fish_deps_detect_pm)
|
||||
if test -z "$pm"
|
||||
echo "No supported package manager found." >&2
|
||||
return 1
|
||||
end
|
||||
switch $pm
|
||||
case paru
|
||||
paru -S --noconfirm $pkg
|
||||
case yay
|
||||
yay -S --noconfirm $pkg
|
||||
case pacman
|
||||
sudo pacman -S --noconfirm $pkg
|
||||
case apt
|
||||
sudo apt install -y $pkg
|
||||
case brew
|
||||
brew install $pkg
|
||||
case pkg
|
||||
sudo pkg install -y $pkg
|
||||
case dnf
|
||||
sudo dnf install -y $pkg
|
||||
case yum
|
||||
sudo yum install -y $pkg
|
||||
end
|
||||
end
|
||||
|
||||
# Upgrade an already-installed package via the system PM.
|
||||
# Usage: _fish_deps_pm_upgrade <pkg>
|
||||
function _fish_deps_pm_upgrade --argument-names pkg
|
||||
set -l pm (_fish_deps_detect_pm)
|
||||
if test -z "$pm"
|
||||
echo "No supported package manager found." >&2
|
||||
return 1
|
||||
end
|
||||
switch $pm
|
||||
case paru
|
||||
paru -S --noconfirm $pkg
|
||||
case yay
|
||||
yay -S --noconfirm $pkg
|
||||
case pacman
|
||||
sudo pacman -S --noconfirm $pkg
|
||||
case apt
|
||||
sudo apt install --only-upgrade -y $pkg
|
||||
case brew
|
||||
brew upgrade $pkg
|
||||
case pkg
|
||||
sudo pkg upgrade -y $pkg
|
||||
case dnf
|
||||
sudo dnf upgrade -y $pkg
|
||||
case yum
|
||||
sudo yum update -y $pkg
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,28 @@
|
||||
# Copyright (C) 2026 Rootiest
|
||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
# Install a package via the system PM.
|
||||
# Usage: _fish_deps_pm_install <pkg>
|
||||
function _fish_deps_pm_install --argument-names pkg
|
||||
set -l pm (_fish_deps_detect_pm)
|
||||
if test -z "$pm"
|
||||
echo "No supported package manager found." >&2
|
||||
return 1
|
||||
end
|
||||
switch $pm
|
||||
case paru yay
|
||||
$pm -S --noconfirm $pkg
|
||||
case pacman
|
||||
sudo pacman -S --noconfirm $pkg
|
||||
case apt
|
||||
sudo apt install -y $pkg
|
||||
case brew
|
||||
brew install $pkg
|
||||
case pkg
|
||||
sudo pkg install -y $pkg
|
||||
case dnf
|
||||
sudo dnf install -y $pkg
|
||||
case yum
|
||||
sudo yum install -y $pkg
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,28 @@
|
||||
# Copyright (C) 2026 Rootiest
|
||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
# Upgrade an already-installed package via the system PM.
|
||||
# Usage: _fish_deps_pm_upgrade <pkg>
|
||||
function _fish_deps_pm_upgrade --argument-names pkg
|
||||
set -l pm (_fish_deps_detect_pm)
|
||||
if test -z "$pm"
|
||||
echo "No supported package manager found." >&2
|
||||
return 1
|
||||
end
|
||||
switch $pm
|
||||
case paru yay
|
||||
$pm -S --noconfirm $pkg
|
||||
case pacman
|
||||
sudo pacman -S --noconfirm $pkg
|
||||
case apt
|
||||
sudo apt install --only-upgrade -y $pkg
|
||||
case brew
|
||||
brew upgrade $pkg
|
||||
case pkg
|
||||
sudo pkg upgrade -y $pkg
|
||||
case dnf
|
||||
sudo dnf upgrade -y $pkg
|
||||
case yum
|
||||
sudo yum update -y $pkg
|
||||
end
|
||||
end
|
||||
@@ -19,7 +19,7 @@ function _fish_deps_update
|
||||
set -l i 1
|
||||
for bin in $_fdc_bins
|
||||
# Skip fisher itself (handled above) and tools that aren't installed
|
||||
if test "$bin" = fisher -o not (type -q $bin)
|
||||
if test "$bin" = fisher; or not type -q $bin
|
||||
set i (math $i + 1)
|
||||
continue
|
||||
end
|
||||
@@ -60,7 +60,7 @@ function _fish_deps_update
|
||||
end
|
||||
|
||||
# Cargo: prefer for Rust tools
|
||||
if test -n "$cargo_crate" -a (type -q cargo)
|
||||
if test -n "$cargo_crate"; and type -q cargo
|
||||
echo "Updating $bin..."
|
||||
cargo install --force $cargo_crate
|
||||
set updated_any 1
|
||||
@@ -69,7 +69,7 @@ function _fish_deps_update
|
||||
end
|
||||
|
||||
# System PM fallback
|
||||
if test -n "$pm_pkg" -a -n "$pm"
|
||||
if test -n "$pm_pkg"; and test -n "$pm"
|
||||
echo "Updating $bin..."
|
||||
_fish_deps_pm_upgrade $pm_pkg
|
||||
set updated_any 1
|
||||
|
||||
Reference in New Issue
Block a user