From 90468b4d41367e885909c76653de1b28cf604ed4 Mon Sep 17 00:00:00 2001 From: Sean Kruzel Date: Mon, 22 Jul 2024 11:28:14 -0400 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20(autocomplete.sh):=20add?= =?UTF-8?q?=20-y=20flag=20to=20remove=5Fcommand=20for=20non-interactive=20?= =?UTF-8?q?script=20removal=20=E2=9C=85=20(test=5Fautocomplete.bats):=20up?= =?UTF-8?q?date=20teardown=20to=20use=20-y=20flag=20for=20non-interactive?= =?UTF-8?q?=20script=20removal?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- autocomplete.sh | 13 ++++++++++--- tests/test_autocomplete.bats | 14 +------------- 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/autocomplete.sh b/autocomplete.sh index eb0ebca..7b5fafe 100755 --- a/autocomplete.sh +++ b/autocomplete.sh @@ -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 @@ -1403,7 +1410,7 @@ install) install_command ;; remove) - remove_command + remove_command "$@" ;; clear) clear_command diff --git a/tests/test_autocomplete.bats b/tests/test_autocomplete.bats index c549928..d2b5b55 100644 --- a/tests/test_autocomplete.bats +++ b/tests/test_autocomplete.bats @@ -16,7 +16,7 @@ setup() { teardown() { # Remove autocomplete.sh installation - autocomplete remove + autocomplete remove -y } @test "which autocomplete returns something" { @@ -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 ] @@ -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 ] -}