Skip to content

Commit

Permalink
📝 (autocomplete.sh): update installation instructions to include sour…
Browse files Browse the repository at this point in the history
…cing config

✨ (autocomplete.sh): add prompt to remove autocomplete script during uninstallation

âś… (test_autocomplete.bats): add check for OPENAI_API_KEY and source config

âś… (test_autocomplete.bats): fix test to check for 'Disabled' instead of 'DISABLED'

âś… (test_autocomplete.bats): correct model name to 'gpt-4o-mini' in tests

âś… (test_autocomplete.bats): improve environment variable test to check for ACSH variables
  • Loading branch information
closedLoop committed Jul 22, 2024
1 parent f3c09e8 commit a1531ab
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 10 deletions.
17 changes: 15 additions & 2 deletions autocomplete.sh
Original file line number Diff line number Diff line change
Expand Up @@ -959,9 +959,10 @@ Please follow the install instructions on https://github.com/closedloop-technolo
echo_green "Autocomplete.sh - LLM Powered Bash Completion - Version $ACSH_VERSION"
echo -e "\e[1;34mInstall Completed\e[0m"
echo
echo "Two more commands to run steps to complete the installation:"
echo "Three quick commands to run to complete the installation:"
echo -e "1. $ \e[1;34msource $bashrc_file\e[0m to enable autocomplete"
echo -e "2. $ \e[1;34mautocomplete model\e[0m \tto select the language model"
echo -e "2. $ \e[1;34msource autocomplete config\e[0m to load environment variables"
echo -e "3. $ \e[1;34mautocomplete model\e[0m \tto select the language model"
echo
echo -e "$ \e[1;30mautocomplete config\e[0m \tto view settings"
echo -e "$ \e[1;30mautocomplete --help\e[0m \tfor additional commands"
Expand Down Expand Up @@ -1022,6 +1023,18 @@ remove_command() {
fi
fi

# Determine where the autocomplete script is located and prompt user to remove it
local autocomplete_script
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
rm "$autocomplete_script"
echo "Removed: $autocomplete_script"
fi
fi

echo "Completed uninstalling autocomplete.sh"
}

Expand Down
22 changes: 14 additions & 8 deletions tests/test_autocomplete.bats
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
#!/usr/bin/env bats

# Set a per-test timeout of 10 seconds
export BATS_TEST_TIMEOUT=10

setup() {
# Install autocomplete.sh and run testing against the main branch
wget -qO- https://autocomplete.sh/install.sh | bash -s -- main

# Source bashrc to make sure autocomplete is available in the current session
source ~/.bashrc

# Assert OPENAI_API_KEY is set
if [ -z "$OPENAI_API_KEY" ]; then
echo "ERROR: OPENAI_API_KEY is not set. Please set the environment variable before running the tests."
exit 1
fi

. autocomplete config
}

teardown() {
Expand All @@ -28,10 +33,10 @@ teardown() {
[[ "$output" =~ [Aa]utocomplete\.sh ]]
}

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

@test "autocomplete model gpt4o-mini and then config should have the string gpt4o-mini" {
Expand All @@ -40,7 +45,7 @@ teardown() {

run autocomplete config
[ "$status" -eq 0 ]
[[ "$output" =~ gpt4o-mini ]]
[[ "$output" =~ gpt-4o-mini ]]
}

@test "autocomplete command 'ls # show largest files' should return something" {
Expand All @@ -50,7 +55,8 @@ teardown() {
}

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

0 comments on commit a1531ab

Please sign in to comment.