feat(deps): add fish-deps unified dependency management command #17

Merged
rootiest merged 21 commits from feat/fish-deps into main 2026-05-19 03:53:52 +00:00
6 changed files with 76 additions and 78 deletions
Showing only changes of commit 0e7e824085 - Show all commits
+13
View File
@@ -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
+4 -6
View File
@@ -21,13 +21,13 @@ function _fish_deps_install
set -l method_labels set -l method_labels
# Cargo — only if cargo is present and the tool has a crate # 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 methods cargo
set -a method_labels "cargo ($cargo_crate)" set -a method_labels "cargo ($cargo_crate)"
end end
# System PM — only if a PM is detected and the tool is in repos # 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 methods pm
set -a method_labels "$pm ($pm_pkg)" set -a method_labels "$pm ($pm_pkg)"
end end
@@ -44,7 +44,6 @@ function _fish_deps_install
set -a methods special-curl set -a methods special-curl
set -a method_labels "curl installer" set -a method_labels "curl installer"
case paru-build case paru-build
# Only useful on Arch; skip if pacman not present
if type -q yay if type -q yay
set -a methods special-yay-paru set -a methods special-yay-paru
set -a method_labels "yay -S paru" set -a method_labels "yay -S paru"
@@ -74,7 +73,7 @@ function _fish_deps_install
# Prompt: install this dep? # Prompt: install this dep?
set_color cyan; echo -n "Install $bin? "; set_color normal set_color cyan; echo -n "Install $bin? "; set_color normal
read -l -P "[Y/n] " _reply 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) set i (math $i + 1)
continue continue
end end
@@ -89,7 +88,7 @@ function _fish_deps_install
set m (math $m + 1) set m (math $m + 1)
end end
read -l -P " Choose [1-"(count $methods)"] (default 1): " _choice 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] set chosen_method $methods[$_choice]
end end
end end
@@ -106,7 +105,6 @@ function _fish_deps_install
curl -sL https://raw.githubusercontent.com/jorgebucaran/fisher/main/functions/fisher.fish | source curl -sL https://raw.githubusercontent.com/jorgebucaran/fisher/main/functions/fisher.fish | source
fisher update fisher update
case special-curl case special-curl
# Currently used for starship
if test "$bin" = starship if test "$bin" = starship
curl -sS https://starship.rs/install.sh | sh curl -sS https://starship.rs/install.sh | sh
end end
-69
View File
@@ -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
+28
View File
@@ -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
+28
View File
@@ -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
+3 -3
View File
@@ -19,7 +19,7 @@ function _fish_deps_update
set -l i 1 set -l i 1
for bin in $_fdc_bins for bin in $_fdc_bins
# Skip fisher itself (handled above) and tools that aren't installed # 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) set i (math $i + 1)
continue continue
end end
@@ -60,7 +60,7 @@ function _fish_deps_update
end end
# Cargo: prefer for Rust tools # 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..." echo "Updating $bin..."
cargo install --force $cargo_crate cargo install --force $cargo_crate
set updated_any 1 set updated_any 1
@@ -69,7 +69,7 @@ function _fish_deps_update
end end
# System PM fallback # System PM fallback
if test -n "$pm_pkg" -a -n "$pm" if test -n "$pm_pkg"; and test -n "$pm"
echo "Updating $bin..." echo "Updating $bin..."
_fish_deps_pm_upgrade $pm_pkg _fish_deps_pm_upgrade $pm_pkg
set updated_any 1 set updated_any 1