mirror of
https://github.com/ethauvin/sdkman-for-fish.git
synced 2025-04-25 05:17:11 -07:00
Merge branch 'dev'
This commit is contained in:
commit
c9fd8d58f2
9 changed files with 181 additions and 78 deletions
|
@ -8,5 +8,8 @@ indent_size = 4
|
|||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
||||
|
||||
[*.{yaml,yml}]
|
||||
indent_size = 2
|
||||
|
||||
[*.md]
|
||||
trim_trailing_whitespace = false
|
||||
|
|
43
.travis.yml
43
.travis.yml
|
@ -1,12 +1,37 @@
|
|||
env:
|
||||
- FISH=release-2
|
||||
- FISH=release-3
|
||||
matrix:
|
||||
include:
|
||||
- dist: bionic
|
||||
env: FISH=2
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- sourceline: "ppa:fish-shell/release-2"
|
||||
packages:
|
||||
- fish
|
||||
- dist: bionic
|
||||
env: FISH=3
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- sourceline: "ppa:fish-shell/release-3"
|
||||
packages:
|
||||
- fish
|
||||
- os: osx
|
||||
env: FISH=2
|
||||
addons:
|
||||
homebrew:
|
||||
packages:
|
||||
- 'test/Homebrew-Formula-fish-2.7.1.rb'
|
||||
update: true # TODO: build should be green without, but isn't
|
||||
- os: osx
|
||||
env: FISH=3
|
||||
addons:
|
||||
homebrew:
|
||||
packages:
|
||||
- fish # --> latest, i.e. >=3.0.2
|
||||
update: true # TODO: build should be green without, but isn't
|
||||
|
||||
sudo: required
|
||||
before_install:
|
||||
- sudo add-apt-repository -y ppa:fish-shell/${FISH}
|
||||
- sudo apt-get update
|
||||
- sudo apt-get -y install fish
|
||||
- curl -s "https://get.sdkman.io" | bash
|
||||
- bash test/prepare_tests.sh
|
||||
|
||||
|
@ -21,5 +46,5 @@ script:
|
|||
- ruby test/completion.rb
|
||||
- fish test/wrapper.fish
|
||||
- fish test/reinitialize.fish
|
||||
- bash -c "source ${HOME}/.sdkman/bin/sdkman-init.sh && sdk install crash 1.3.0 && sdk uninstall crash 1.3.0" && fish test/10_zombies_new.fish
|
||||
- bash -c "rm -rf ~/.sdkman && sed -i 's/^.*\(sdkman\|SDKMAN\).*$//g' ~/.bashrc && echo 'SDKMAN uninstalled'" && fish -c "echo 'y' | sdk" && fish -c "sdk version"
|
||||
- fish -c "sdk install crash 1.3.0; and sdk uninstall crash 1.3.0" > /dev/null && fish test/check_for_path_zombies.fish
|
||||
- bash test/remove_sdkman.sh > /dev/null && fish -c "echo 'y' | sdk" > /dev/null && fish -c "sdk version"
|
||||
|
|
|
@ -5,7 +5,11 @@
|
|||
Makes command `sdk` from [SDKMAN!] usable from fish, including auto-completion.
|
||||
Also adds binaries from installed SDKs to the PATH.
|
||||
|
||||
Tested with fish 2.7.1 and 3.0.2, and SDKMAN! 5.7.4.
|
||||
Version 1.4.0 tested with
|
||||
|
||||
- fish 2.7.1 and 3.0.2, and
|
||||
- SDKMAN! 5.7.4, on
|
||||
- Ubuntu 18.04 LTS and macOS 10.13.
|
||||
|
||||
## Install
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
# Guard: SDKMAN! needs to be installed
|
||||
if not test -f "$HOME/.sdkman/bin/sdkman-init.sh"
|
||||
exit 0
|
||||
exit 0
|
||||
end
|
||||
|
||||
# # # # # #
|
||||
|
@ -14,45 +14,45 @@ end
|
|||
# # # # # #
|
||||
|
||||
# Test if there is no command
|
||||
function __fish_sdkman_no_command
|
||||
set cmd (commandline -opc)
|
||||
function __fish_sdkman_no_command
|
||||
set cmd (commandline -opc)
|
||||
|
||||
if [ (count $cmd) -eq 1 ]
|
||||
return 0
|
||||
end
|
||||
return 1
|
||||
if [ (count $cmd) -eq 1 ]
|
||||
return 0
|
||||
end
|
||||
return 1
|
||||
end
|
||||
|
||||
# Test if the main command matches one of the parameters
|
||||
function __fish_sdkman_using_command
|
||||
set cmd (commandline -opc)
|
||||
set cmd (commandline -opc)
|
||||
|
||||
if [ (count $cmd) -eq 2 ]
|
||||
if contains $cmd[2] $argv
|
||||
return 0
|
||||
if [ (count $cmd) -eq 2 ]
|
||||
if contains $cmd[2] $argv
|
||||
return 0
|
||||
end
|
||||
end
|
||||
end
|
||||
return 1
|
||||
return 1
|
||||
end
|
||||
|
||||
function __fish_sdkman_specifying_candidate
|
||||
set cmd (commandline -opc)
|
||||
set cmd (commandline -opc)
|
||||
|
||||
if [ (count $cmd) -eq 3 ] # currently, sdk does not support multiple versions
|
||||
if contains $cmd[2] $argv ]
|
||||
return 0
|
||||
if [ (count $cmd) -eq 3 ] # currently, sdk does not support multiple versions
|
||||
if contains $cmd[2] $argv
|
||||
return 0
|
||||
end
|
||||
end
|
||||
end
|
||||
return 1
|
||||
return 1
|
||||
end
|
||||
|
||||
function __fish_sdkman_command_has_enough_parameters
|
||||
set cmd (commandline -opc)
|
||||
|
||||
if [ (count $cmd) -ge (math $argv[1] + 2) ]; and contains $cmd[2] $argv[2..-1]
|
||||
return 0
|
||||
end
|
||||
return 1
|
||||
set cmd (commandline -opc)
|
||||
|
||||
if [ (count $cmd) -ge (math $argv[1] + 2) ]; and contains $cmd[2] $argv[2..-1]
|
||||
return 0
|
||||
end
|
||||
return 1
|
||||
end
|
||||
|
||||
# # # # # #
|
||||
|
@ -60,22 +60,22 @@ end
|
|||
# # # # # #
|
||||
|
||||
function __fish_sdkman_candidates
|
||||
cat "$HOME"/.sdkman/var/candidates | tr ',' '\n'
|
||||
cat "$HOME"/.sdkman/var/candidates | tr ',' '\n'
|
||||
end
|
||||
|
||||
function __fish_sdkman_candidates_with_versions
|
||||
set regexpHome (string replace -a '/' '\\/' "$HOME/")
|
||||
find "$HOME"/.sdkman/candidates/ -name '*current*' -printf "%h\n" \
|
||||
| sed -e "s/$regexpHome//" \
|
||||
| cut -d '/' -f 3 \
|
||||
| sort -u
|
||||
set regexpHome (string replace -a '/' '\\/' "$HOME/")
|
||||
|
||||
find "$HOME"/.sdkman/candidates/ -mindepth 2 -maxdepth 2 -name '*current' \
|
||||
| awk -F '/' '{ print $(NF-1) }' \
|
||||
| sort -u
|
||||
end
|
||||
|
||||
function __fish_sdkman_installed_versions
|
||||
set cmd (commandline -opc)
|
||||
if [ -d "$HOME"/.sdkman/candidates/$cmd[3]/current ]
|
||||
ls -v1 "$HOME"/.sdkman/candidates/$cmd[3] | grep -v current
|
||||
end
|
||||
set cmd (commandline -opc)
|
||||
if [ -d "$HOME"/.sdkman/candidates/$cmd[3]/current ]
|
||||
ls -v1 "$HOME"/.sdkman/candidates/$cmd[3] | grep -v current
|
||||
end
|
||||
end
|
||||
|
||||
# # # # # #
|
||||
|
@ -87,26 +87,26 @@ complete -c sdk -f -n '__fish_sdkman_no_command' \
|
|||
-a 'i install' \
|
||||
-d 'Install new version'
|
||||
complete -c sdk -f -n '__fish_sdkman_using_command i install' \
|
||||
-a "(__fish_sdkman_candidates)"
|
||||
-a "(__fish_sdkman_candidates)"
|
||||
complete -c sdk -f -n '__fish_sdkman_specifying_candidate i install' \
|
||||
# TODO complete available versions --> #4
|
||||
-a 'a.b.c' \
|
||||
-d "version list unavailable"
|
||||
-d "version list unavailable"
|
||||
complete -c sdk -f -n '__fish_sdkman_specifying_candidate i install' \
|
||||
-a 'x.y.z' \
|
||||
-d "Add your own; specify path!"
|
||||
-d "Add your own; specify path!"
|
||||
# Implicit: complete files as fourth parameter
|
||||
complete -c sdk -f -n '__fish_sdkman_command_has_enough_parameters 3 i install'
|
||||
complete -c sdk -f -n '__fish_sdkman_command_has_enough_parameters 3 i install'
|
||||
# block
|
||||
|
||||
# uninstall
|
||||
complete -c sdk -f -n '__fish_sdkman_no_command' \
|
||||
-a 'rm uninstall' -d 'Uninstall version'
|
||||
complete -c sdk -f -n '__fish_sdkman_using_command rm uninstall' \
|
||||
-a "(__fish_sdkman_candidates_with_versions)"
|
||||
-a "(__fish_sdkman_candidates_with_versions)"
|
||||
complete -c sdk -f -n '__fish_sdkman_specifying_candidate rm uninstall' \
|
||||
-a "(__fish_sdkman_installed_versions)"
|
||||
complete -c sdk -f -n '__fish_sdkman_command_has_enough_parameters 2 rm uninstall'
|
||||
-a "(__fish_sdkman_installed_versions)"
|
||||
complete -c sdk -f -n '__fish_sdkman_command_has_enough_parameters 2 rm uninstall'
|
||||
# block
|
||||
|
||||
# list
|
||||
|
@ -114,19 +114,19 @@ complete -c sdk -f -n '__fish_sdkman_no_command' \
|
|||
-a 'ls list' \
|
||||
-d 'List versions'
|
||||
complete -c sdk -f -n '__fish_sdkman_using_command ls list' \
|
||||
-a "(__fish_sdkman_candidates)"
|
||||
complete -c sdk -f -n '__fish_sdkman_command_has_enough_parameters 1 ls list'
|
||||
# block
|
||||
-a "(__fish_sdkman_candidates)"
|
||||
complete -c sdk -f -n '__fish_sdkman_command_has_enough_parameters 1 ls list'
|
||||
# block
|
||||
|
||||
# use
|
||||
complete -c sdk -f -n '__fish_sdkman_no_command' \
|
||||
-a 'u use' \
|
||||
-d 'Use specific version'
|
||||
complete -c sdk -f -n '__fish_sdkman_using_command u use' \
|
||||
-a "(__fish_sdkman_candidates_with_versions)"
|
||||
-a "(__fish_sdkman_candidates_with_versions)"
|
||||
complete -c sdk -f -n '__fish_sdkman_specifying_candidate u use' \
|
||||
-a "(__fish_sdkman_installed_versions)"
|
||||
complete -c sdk -f -n '__fish_sdkman_command_has_enough_parameters 2 u use'
|
||||
-a "(__fish_sdkman_installed_versions)"
|
||||
complete -c sdk -f -n '__fish_sdkman_command_has_enough_parameters 2 u use'
|
||||
# block
|
||||
|
||||
# default
|
||||
|
@ -134,10 +134,10 @@ complete -c sdk -f -n '__fish_sdkman_no_command' \
|
|||
-a 'd default' \
|
||||
-d 'Set default version'
|
||||
complete -c sdk -f -n '__fish_sdkman_using_command d default' \
|
||||
-a "(__fish_sdkman_candidates_with_versions)"
|
||||
-a "(__fish_sdkman_candidates_with_versions)"
|
||||
complete -c sdk -f -n '__fish_sdkman_specifying_candidate d default' \
|
||||
-a "(__fish_sdkman_installed_versions)"
|
||||
complete -c sdk -f -n '__fish_sdkman_command_has_enough_parameters 2 d default'
|
||||
-a "(__fish_sdkman_installed_versions)"
|
||||
complete -c sdk -f -n '__fish_sdkman_command_has_enough_parameters 2 d default'
|
||||
# block
|
||||
|
||||
# current
|
||||
|
@ -145,8 +145,8 @@ complete -c sdk -f -n '__fish_sdkman_no_command' \
|
|||
-a 'c current' \
|
||||
-d 'Display current version'
|
||||
complete -c sdk -f -n '__fish_sdkman_using_command c current' \
|
||||
-a "(__fish_sdkman_candidates)"
|
||||
complete -c sdk -f -n '__fish_sdkman_command_has_enough_parameters 1 c current'
|
||||
-a "(__fish_sdkman_candidates)"
|
||||
complete -c sdk -f -n '__fish_sdkman_command_has_enough_parameters 1 c current'
|
||||
# block
|
||||
|
||||
# upgrade
|
||||
|
@ -154,29 +154,29 @@ complete -c sdk -f -n '__fish_sdkman_no_command' \
|
|||
-a 'ug upgrade' \
|
||||
-d 'Display what is outdated'
|
||||
complete -c sdk -f -n '__fish_sdkman_using_command ug upgrade' \
|
||||
-a "(__fish_sdkman_candidates_with_versions)"
|
||||
complete -c sdk -f -n '__fish_sdkman_command_has_enough_parameters 1 ug upgrade'
|
||||
-a "(__fish_sdkman_candidates_with_versions)"
|
||||
complete -c sdk -f -n '__fish_sdkman_command_has_enough_parameters 1 ug upgrade'
|
||||
# block
|
||||
|
||||
# version
|
||||
complete -c sdk -f -n '__fish_sdkman_no_command' \
|
||||
-a 'v version' \
|
||||
-d 'Display version'
|
||||
complete -c sdk -f -n '__fish_sdkman_command_has_enough_parameters 0 v version'
|
||||
complete -c sdk -f -n '__fish_sdkman_command_has_enough_parameters 0 v version'
|
||||
# block
|
||||
|
||||
# broadcast
|
||||
complete -c sdk -f -n '__fish_sdkman_no_command' \
|
||||
-a 'b broadcast' \
|
||||
-d 'Display broadcast message'
|
||||
complete -c sdk -f -n '__fish_sdkman_command_has_enough_parameters 0 b broadcast'
|
||||
complete -c sdk -f -n '__fish_sdkman_command_has_enough_parameters 0 b broadcast'
|
||||
# block
|
||||
|
||||
# help
|
||||
complete -c sdk -f -n '__fish_sdkman_no_command' \
|
||||
-a 'h help' \
|
||||
-d 'Display help message'
|
||||
complete -c sdk -f -n '__fish_sdkman_command_has_enough_parameters 0 h help'
|
||||
complete -c sdk -f -n '__fish_sdkman_command_has_enough_parameters 0 h help'
|
||||
# block
|
||||
|
||||
# offline
|
||||
|
@ -189,7 +189,7 @@ complete -c sdk -f -n '__fish_sdkman_using_command offline' \
|
|||
complete -c sdk -f -n '__fish_sdkman_using_command offline' \
|
||||
-a 'disable' \
|
||||
-d 'Turn on all features'
|
||||
complete -c sdk -f -n '__fish_sdkman_command_has_enough_parameters 1 offline'
|
||||
complete -c sdk -f -n '__fish_sdkman_command_has_enough_parameters 1 offline'
|
||||
# block
|
||||
|
||||
# selfupdate
|
||||
|
@ -199,14 +199,14 @@ complete -c sdk -f -n '__fish_sdkman_no_command' \
|
|||
complete -c sdk -f -n '__fish_sdkman_using_command selfupdate' \
|
||||
-a 'force' \
|
||||
-d 'Force re-install of current version'
|
||||
complete -c sdk -f -n '__fish_sdkman_command_has_enough_parameters 1 selfupdate'
|
||||
complete -c sdk -f -n '__fish_sdkman_command_has_enough_parameters 1 selfupdate'
|
||||
# block
|
||||
|
||||
# update
|
||||
complete -c sdk -f -n '__fish_sdkman_no_command' \
|
||||
-a 'update' \
|
||||
-d 'Reload the candidate list'
|
||||
complete -c sdk -f -n '__fish_sdkman_command_has_enough_parameters 0 update'
|
||||
complete -c sdk -f -n '__fish_sdkman_command_has_enough_parameters 0 update'
|
||||
# block
|
||||
|
||||
# flush
|
||||
|
@ -222,5 +222,5 @@ complete -c sdk -f -n '__fish_sdkman_using_command flush' \
|
|||
complete -c sdk -f -n '__fish_sdkman_using_command flush' \
|
||||
-a 'temp' \
|
||||
-d 'Clear installation prep folder'
|
||||
complete -c sdk -f -n '__fish_sdkman_command_has_enough_parameters 1 flush'
|
||||
complete -c sdk -f -n '__fish_sdkman_command_has_enough_parameters 1 flush'
|
||||
# block
|
||||
|
|
|
@ -22,8 +22,8 @@ if begin not test -f "$__fish_sdkman_noexport_init";
|
|||
or env test "$__fish_sdkman_init" -nt "$__fish_sdkman_noexport_init"
|
||||
end
|
||||
mkdir -p (dirname $__fish_sdkman_noexport_init)
|
||||
sed -e 's/^\(\s*\).*\(export\|to_path\).*$/\1:/g' "$__fish_sdkman_init" \
|
||||
> $__fish_sdkman_noexport_init
|
||||
sed -E -e 's/^(\s*).*(export|to_path).*$/\1:/g' "$__fish_sdkman_init" \
|
||||
> "$__fish_sdkman_noexport_init"
|
||||
end
|
||||
|
||||
# Runs the given command in bash, capturing some side effects
|
||||
|
@ -66,7 +66,7 @@ function __fish_sdkman_run_in_bash
|
|||
if test -n value
|
||||
set -gx $var $value
|
||||
# Note: This makes SDKMAN_OFFLINE_MODE an environment variable.
|
||||
# That gives it the behavariour we _want_!
|
||||
# That gives it the behaviour we _want_!
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -77,7 +77,7 @@ end
|
|||
# If this is a subshell of a(n initialized) fish owned by the same user,
|
||||
# no initialization necessary.
|
||||
# Otherwise:
|
||||
if not set -q SDKMAN_DIR; or test (stat -c "%U" $SDKMAN_DIR) != (whoami)
|
||||
if not set -q SDKMAN_DIR; or test (ls -ld "$SDKMAN_DIR" | awk '{print $3}') != (whoami)
|
||||
set -e SDKMAN_DIR
|
||||
__fish_sdkman_run_in_bash "source $__fish_sdkman_init"
|
||||
end
|
||||
|
|
60
test/Homebrew-Formula-fish-2.7.1.rb
Normal file
60
test/Homebrew-Formula-fish-2.7.1.rb
Normal file
|
@ -0,0 +1,60 @@
|
|||
class HomebrewFormulaFish271 < Formula
|
||||
desc "User-friendly command-line shell for UNIX-like operating systems"
|
||||
homepage "https://fishshell.com"
|
||||
url "https://github.com/fish-shell/fish-shell/releases/download/2.7.1/fish-2.7.1.tar.gz"
|
||||
mirror "https://fishshell.com/files/2.7.1/fish-2.7.1.tar.gz"
|
||||
sha256 "e42bb19c7586356905a58578190be792df960fa81de35effb1ca5a5a981f0c5a"
|
||||
|
||||
bottle do
|
||||
sha256 "affac16a396410a500241266dbbbd8752562c9b800d9e4f2ef8de279c6fdb6aa" => :high_sierra
|
||||
sha256 "335538a7ea7f9613474f7321af0a1d519b61b0fc4be97a1744a7ea7bef7ff7e3" => :sierra
|
||||
sha256 "463cfa8edc0603761f25e0ba4e49524f69a1d856263d370d1de5fb8698dd5ccf" => :el_capitan
|
||||
end
|
||||
|
||||
head do
|
||||
url "https://github.com/fish-shell/fish-shell.git", :shallow => false
|
||||
|
||||
depends_on "autoconf" => :build
|
||||
depends_on "automake" => :build
|
||||
depends_on "doxygen" => :build
|
||||
end
|
||||
|
||||
depends_on "pcre2"
|
||||
|
||||
def install
|
||||
system "autoreconf", "--no-recursive" if build.head?
|
||||
|
||||
# In Homebrew's 'superenv' sed's path will be incompatible, so
|
||||
# the correct path is passed into configure here.
|
||||
args = %W[
|
||||
--prefix=#{prefix}
|
||||
--with-extra-functionsdir=#{HOMEBREW_PREFIX}/share/fish/vendor_functions.d
|
||||
--with-extra-completionsdir=#{HOMEBREW_PREFIX}/share/fish/vendor_completions.d
|
||||
--with-extra-confdir=#{HOMEBREW_PREFIX}/share/fish/vendor_conf.d
|
||||
SED=/usr/bin/sed
|
||||
]
|
||||
system "./configure", *args
|
||||
system "make", "install"
|
||||
end
|
||||
|
||||
def caveats; <<~EOS
|
||||
You will need to add:
|
||||
#{HOMEBREW_PREFIX}/bin/fish
|
||||
to /etc/shells.
|
||||
|
||||
Then run:
|
||||
chsh -s #{HOMEBREW_PREFIX}/bin/fish
|
||||
to make fish your default shell.
|
||||
EOS
|
||||
end
|
||||
|
||||
def post_install
|
||||
(pkgshare/"vendor_functions.d").mkpath
|
||||
(pkgshare/"vendor_completions.d").mkpath
|
||||
(pkgshare/"vendor_conf.d").mkpath
|
||||
end
|
||||
|
||||
test do
|
||||
system "#{bin}/fish", "-c", "echo"
|
||||
end
|
||||
end
|
5
test/remove_sdkman.sh
Normal file
5
test/remove_sdkman.sh
Normal file
|
@ -0,0 +1,5 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
rm -rf "${HOME}/.sdkman" \
|
||||
&& sed -i'.bak' -E -e 's/^.*(sdkman|SDKMAN).*$//g' "${HOME}/.bashrc" \
|
||||
&& echo 'SDKMAN! uninstalled'
|
|
@ -15,8 +15,14 @@ set check_count (math "3 * $test_count")
|
|||
|
||||
set sdk_init "$HOME/.sdkman/bin/sdkman-init.sh"
|
||||
|
||||
function checksum -a file
|
||||
sha256sum $file | cut -d " " -f 1
|
||||
if [ (uname) = "Linux" ]
|
||||
function checksum -a file
|
||||
sha256sum $file | cut -d " " -f 1
|
||||
end
|
||||
else # assume macOS
|
||||
function checksum -a file
|
||||
shasum -a 256 $file | cut -d " " -f 1
|
||||
end
|
||||
end
|
||||
|
||||
echo "Testing the sdk wrapper"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue