#!/usr/bin/env bash

cat <<EOF >.tool-versions
tiny latest
shfmt latest
zprint latest
EOF

# install/uninstall multiple
mise plugin install tiny shfmt zprint
assert_contains "mise plugin ls" "tiny"
assert_contains "mise plugin ls" "shfmt"
assert_contains "mise plugin ls" "zprint"

rm -rf "$MISE_DATA_DIR/plugins/tiny"
mise plugin install https://github.com/mise-plugins/rtx-tiny.git
assert_contains "mise plugin ls" "tiny"
mise plugin install -f tiny
assert_contains "mise plugin ls" "tiny"

rm -rf "$MISE_DATA_DIR/plugins/tiny"
mise plugin install tiny https://github.com/mise-plugins/rtx-tiny
assert_contains "mise plugin ls" "tiny"

rm -rf "$MISE_DATA_DIR/plugins/zprint"
mise plugin install --all
assert_contains "mise plugin ls" "zprint"

mise plugin uninstall tiny
assert_not_contains "mise plugin ls" "tiny"
mise plugin uninstall tiny

mise plugin update
mise plugin update shfmt
mise i

assert_contains "mise plugin install mise-x 2>&1 || true" "No repository found for plugin mise-x"
assert_contains "mise plugin add node 2>&1 || true" "node is a core plugin and does not need to be installed"
