feat(deps): add fish-deps unified dependency management command #17
@@ -11,7 +11,20 @@ function _fish_deps_install
|
|||||||
|
|
||||||
set -l i 1
|
set -l i 1
|
||||||
for bin in $_fdc_bins
|
for bin in $_fdc_bins
|
||||||
|
# Determine if this dep needs attention: missing, or fish < 4.0
|
||||||
|
set -l needs_install 0
|
||||||
|
set -l upgrade_label Install
|
||||||
if not type -q $bin
|
if not type -q $bin
|
||||||
|
set needs_install 1
|
||||||
|
else if test "$bin" = fish
|
||||||
|
set -l _major (fish --version 2>&1 | string match -r 'version (\d+)')[2]
|
||||||
|
if test -n "$_major"; and test "$_major" -lt 4
|
||||||
|
set needs_install 1
|
||||||
|
set upgrade_label "Upgrade"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if test $needs_install -eq 1
|
||||||
set -l cargo_crate $_fdc_cargo[$i]
|
set -l cargo_crate $_fdc_cargo[$i]
|
||||||
set -l pm_pkg $_fdc_pm[$i]
|
set -l pm_pkg $_fdc_pm[$i]
|
||||||
set -l special $_fdc_special[$i]
|
set -l special $_fdc_special[$i]
|
||||||
@@ -90,8 +103,8 @@ function _fish_deps_install
|
|||||||
continue
|
continue
|
||||||
end
|
end
|
||||||
|
|
||||||
# Prompt: install this dep?
|
# Prompt: install/upgrade this dep?
|
||||||
read -l -P (set_color cyan)"Install $bin?"(set_color normal)" [Y/n] " _reply
|
read -l -P (set_color cyan)"$upgrade_label $bin?"(set_color normal)" [Y/n] " _reply
|
||||||
if test "$_reply" = n; or test "$_reply" = N
|
if test "$_reply" = n; or test "$_reply" = N
|
||||||
set i (math $i + 1)
|
set i (math $i + 1)
|
||||||
continue
|
continue
|
||||||
@@ -112,7 +125,7 @@ function _fish_deps_install
|
|||||||
set chosen_method $methods[$_choice]
|
set chosen_method $methods[$_choice]
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
set_color brblack; echo " Installing via $method_labels[1]"; set_color normal
|
set_color brblack; echo " "(string lower $upgrade_label)"ing via $method_labels[1]"; set_color normal
|
||||||
end
|
end
|
||||||
|
|
||||||
# Execute chosen method
|
# Execute chosen method
|
||||||
@@ -189,9 +202,14 @@ function _fish_deps_install
|
|||||||
|
|
||||||
if test $status -eq 0
|
if test $status -eq 0
|
||||||
set installed_any 1
|
set installed_any 1
|
||||||
set_color green; echo " $bin installed."; set_color normal
|
set_color green; echo " $bin "(string lower $upgrade_label)"ed."; set_color normal
|
||||||
|
if test "$bin" = fish
|
||||||
|
set_color yellow
|
||||||
|
echo " Fish upgraded — restart your shell to use the new version."
|
||||||
|
set_color normal
|
||||||
|
end
|
||||||
else
|
else
|
||||||
set_color red; echo " $bin install failed."; set_color normal
|
set_color red; echo " $bin "(string lower $upgrade_label)" failed."; set_color normal
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
set i (math $i + 1)
|
set i (math $i + 1)
|
||||||
|
|||||||
@@ -7,6 +7,17 @@ function _fish_deps_status
|
|||||||
|
|
||||||
function __fds_print_dep --argument-names bin tier
|
function __fds_print_dep --argument-names bin tier
|
||||||
if type -q $bin
|
if type -q $bin
|
||||||
|
# Special version check: fish < 4.0 is functionally incompatible
|
||||||
|
if test "$bin" = fish
|
||||||
|
set -l _major (fish --version 2>&1 | string match -r 'version (\d+)')[2]
|
||||||
|
if test -n "$_major"; and test "$_major" -lt 4
|
||||||
|
set -l _ver (fish --version 2>&1 | string replace 'fish, ' '')
|
||||||
|
set_color yellow; echo -n " ⚠ "; set_color normal
|
||||||
|
echo -n "$bin "
|
||||||
|
set_color brblack; echo "($_ver — upgrade to 4.0+ required)"; set_color normal
|
||||||
|
return
|
||||||
|
end
|
||||||
|
end
|
||||||
set_color green; echo -n " ✓ "; set_color normal
|
set_color green; echo -n " ✓ "; set_color normal
|
||||||
echo -n "$bin "
|
echo -n "$bin "
|
||||||
set_color brblack; echo "(Found at "(type -p $bin)")"; set_color normal
|
set_color brblack; echo "(Found at "(type -p $bin)")"; set_color normal
|
||||||
|
|||||||
Reference in New Issue
Block a user