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(uninstall): fix uninstall completions #1869

Merged
merged 1 commit into from
Apr 6, 2024
Merged

fix(uninstall): fix uninstall completions #1869

merged 1 commit into from
Apr 6, 2024

Conversation

jdx
Copy link
Owner

@jdx jdx commented Apr 6, 2024

Fixes #1861

@jdx jdx enabled auto-merge (squash) April 6, 2024 16:54
Copy link

codacy-production bot commented Apr 6, 2024

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
+0.00%
Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (9138e2e) 16632 13846 83.25%
Head commit (41d81ec) 16632 (+0) 13846 (+0) 83.25% (+0.00%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#1869) 0 0 ∅ (not applicable)

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

See your quality gate settings    Change summary preferences

You may notice some variations in coverage metrics with the latest Coverage engine update. For more details, visit the documentation

@jdx jdx merged commit 2738afd into main Apr 6, 2024
9 checks passed
@jdx jdx deleted the complete-rm branch April 6, 2024 16:57
if [ ! -z "$prefix" ]; then
prefix="--prefix $prefix"
fi
versions=$(mise ls --installed $tool $prefix | awk '{print $2}' | sed '1!G;h;$!d')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was also playing around with this. Does this work? ls returns another format than ls-remote. Also it potentially list missing versions.

My approach would have been

complete "tool@version" run=r#"
prev="{{words[PREV]}}"
cur="{{words[CURRENT]}}"
declare -a rm=("uninstall" "remove" "rm")
case $cur in
  *@*)
    tool="$(echo "$cur" | cut -d'@' -f1)"
    prefix="$(echo "$cur" | cut -d'@' -f2)"

    if [[ " ${rm[@]} " =~ " ${prev} " ]]; then
      versions=$(mise ls --no-header $tool | grep -v '(missing)' | awk '{print $2}' | sed '1!G;h;$!d')
    else
      versions=$(mise ls-remote $tool $prefix | sed '1!G;h;$!d')
    fi

    for version in $versions; do
      echo "$tool@$version"
    done
    ;;
  *)
    if [[ " ${rm[@]} " =~ " ${prev} " ]]; then
      plugins=$(mise plugins --core --user)
    else
      plugins=$(mise plugins --all)
    fi

    for plugin in $plugins; do
      echo "$plugin@"
    done
    ;;
esac
"#

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it would work, but I'd be hesitant to hardcode the aliases in the extras file. One problem with my solution is it shows plugins that have no installed versions but I feel it's at least an improvement.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah i see, the --installed flag filters the missing already. agree that hardcoding aliases is indeed not nice.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

another note is you never need to pass--no-header, the header is omitted when it isn't a tty

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

mise remove tool@ completion suggests all available (not installed) versions
2 participants