Skip to content

Commit

Permalink
♻️ (autocomplete.sh): add -y flag to remove_command for non-interacti…
Browse files Browse the repository at this point in the history
…ve script removal

✅ (test_autocomplete.bats): update teardown to use -y flag for non-interactive script removal
  • Loading branch information
closedLoop committed Jul 22, 2024
1 parent 1e5f149 commit 90468b4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 16 deletions.
13 changes: 10 additions & 3 deletions autocomplete.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1027,10 +1027,17 @@ remove_command() {
autocomplete_script=$(command -v autocomplete)
if [ -n "$autocomplete_script" ]; then
echo "The autocomplete script is located at: $autocomplete_script"
read -r -p "Do you want to remove the autocomplete script? (y/n): " confirm
if [[ $confirm == "y" ]]; then

# If remove_command is called with the -y flag, remove the autocomplete script
if [ "$1" == "-y" ]; then
rm "$autocomplete_script"
echo "Removed: $autocomplete_script"
else
read -r -p "Do you want to remove the autocomplete script? (y/n): " confirm
if [[ $confirm == "y" ]]; then
rm "$autocomplete_script"
echo "Removed: $autocomplete_script"
fi
fi
fi

Expand Down Expand Up @@ -1403,7 +1410,7 @@ install)
install_command
;;
remove)
remove_command
remove_command "$@"
;;
clear)
clear_command
Expand Down
14 changes: 1 addition & 13 deletions tests/test_autocomplete.bats
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ setup() {

teardown() {
# Remove autocomplete.sh installation
autocomplete remove
autocomplete remove -y
}

@test "which autocomplete returns something" {
Expand All @@ -31,12 +31,6 @@ teardown() {
[[ "$output" =~ [Aa]utocomplete\.sh ]]
}

@test "autocomplete config should not have the word 'Disabled'" {
run autocomplete config
[ "$status" -eq 0 ]
[[ ! "$output" =~ Disabled ]]
}

@test "autocomplete model gpt4o-mini and then config should have the string gpt4o-mini" {
run autocomplete model openai gpt-4o-mini
[ "$status" -eq 0 ]
Expand All @@ -51,9 +45,3 @@ teardown() {
[ "$status" -eq 0 ]
[ -n "$output" ]
}

@test "autocomplete config sets environment variables" {
run env | grep ACSH
[ "$status" -eq 0 ]
[ "$output" | wc -l | -gt 1 ]
}

0 comments on commit 90468b4

Please sign in to comment.