Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Completions for custom install path #51

Merged
merged 2 commits into from
Apr 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +0,0 @@
test/*_fish
test/*_bash
3 changes: 3 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

This file was deleted.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and
this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Fixes

- Completions use custom SDKMAN! install path (#48; thanks, @Bryan2333!)

## [2.0.0] - 2023-06-27

### Breaking
Expand Down
8 changes: 4 additions & 4 deletions completions/sdk.fish
Original file line number Diff line number Diff line change
Expand Up @@ -60,21 +60,21 @@ end
# # # # # #

function __fish_sdkman_candidates
cat "$HOME"/.sdkman/var/candidates | tr ',' '\n'
cat "$SDKMAN_DIR"/var/candidates | string replace -a -r ',' '\n'
end

function __fish_sdkman_candidates_with_versions
set regexpHome (string replace -a '/' '\\/' "$HOME/")

find "$HOME"/.sdkman/candidates/ -mindepth 2 -maxdepth 2 -name '*current' \
find "$SDKMAN_DIR"/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
if [ -d "$SDKMAN_DIR"/candidates/$cmd[3]/current ]
ls -v1 "$SDKMAN_DIR"/candidates/$cmd[3] | grep -v current
end
end

Expand Down
23 changes: 23 additions & 0 deletions test/features/corner_cases.feature
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,29 @@ Feature: Corner Cases
And environment variable SDKMAN_DIR has value "/tmp/sdkman"
And environment variable ANT_HOME has value "/tmp/sdkman/candidates/ant/current"

Scenario Outline: Completions with custom installation path
Given SDKMAN! is installed at /tmp/sdkman
And fish config file config_sdk.fish exists with content
"""
set -g __sdkman_custom_dir /tmp/sdkman
"""
When the user enters "<cmd>" into the prompt
Then completion should propose "<completions>"
Examples:
| cmd | completions |
| install an | ant |
| uninstall an | ant |
| uninstall ant 1 | 1.10.1, 1.9.9 |
| list an | ant |
| use an | ant |
| use ant 1 | 1.10.1, 1.9.9 |
| default an | ant |
| default ant 1 | 1.10.1, 1.9.9 |
| home an | ant |
| home ant 1 | 1.10.1, 1.9.9 |
| current an | ant |
| upgrade an | ant |

@pending # cf. issue #10
Scenario: PATH should contain only valid paths
Given candidate kscript is installed
Expand Down