diff --git a/README.md b/README.md index ddc72fe..80fa482 100644 --- a/README.md +++ b/README.md @@ -60,6 +60,8 @@ getpkg version ### Information +- **`getpkg list`** - List all available packages with status +- **`getpkg clean`** - Clean up orphaned configs and symlinks - **`getpkg version`** - Show getpkg version - **`getpkg help`** - Show detailed help - **`getpkg autocomplete`** - Show available commands for completion @@ -99,14 +101,14 @@ Tools are automatically downloaded for your architecture, with fallback to unive ### Installing Popular Tools ```bash -# Install development tools -getpkg whatsdirty # Fast grep alternative -getpkg fd # Fast find alternative -getpkg bat # Cat with syntax highlighting +# Install available tools +getpkg install dehydrate # File to C++ code generator +getpkg install bb64 # Bash base64 encoder/decoder -# Install system utilities -getpkg whatsdirty # Check git repo status -getpkg sos # Simple object storage client +# Development tools (for repository development) +getpkg install whatsdirty # Check git repo status +getpkg install sos # Simple object storage client +getpkg install gp # Git push utility ``` ### Publishing Your Own Tools diff --git a/bb64/README.md b/bb64/README.md index 6325345..a499d27 100644 --- a/bb64/README.md +++ b/bb64/README.md @@ -26,6 +26,8 @@ Usage: bb64 -[i|d] BASE64COMMAND Displays the decoded command bb64 -e COMMAND Encodes the command and prints the result bb64 -u Updates bb64 to the latest version (uses docker) + bb64 -v Prints the version number + bb64 version Prints the version number ``` # Implementation Notes diff --git a/bb64/src/bb64.cpp b/bb64/src/bb64.cpp index e75b1a9..ec8e002 100644 --- a/bb64/src/bb64.cpp +++ b/bb64/src/bb64.cpp @@ -150,6 +150,7 @@ Usage: bb64 -u Updates bb64 to the latest version (uses docker) bb64 -v Prints the version number + bb64 version Prints the version number )" << std::endl; return -1; diff --git a/bb64/test.sh b/bb64/test.sh new file mode 100755 index 0000000..9aa8e75 --- /dev/null +++ b/bb64/test.sh @@ -0,0 +1,135 @@ +#!/bin/bash + +set -euo pipefail + +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +PROJECT="bb64" +BB64="$SCRIPT_DIR/output/$PROJECT" +TEST_DIR="$SCRIPT_DIR/test_temp" + +# Colors for output +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +NC='\033[0m' # No Color + +# Test counters +TESTS_PASSED=0 +TESTS_FAILED=0 + +# Function to print test results +print_test_result() { + local test_name="$1" + local result="$2" + if [ "$result" -eq 0 ]; then + echo -e "${GREEN}✓${NC} $test_name" + TESTS_PASSED=$((TESTS_PASSED + 1)) + else + echo -e "${RED}✗${NC} $test_name" + TESTS_FAILED=$((TESTS_FAILED + 1)) + fi +} + +# Function to cleanup test artifacts +cleanup() { + echo -e "\n${YELLOW}Cleaning up test artifacts...${NC}" + rm -rf "$TEST_DIR" +} + +# Set up trap to ensure cleanup runs +trap cleanup EXIT + +# Create test directory +mkdir -p "$TEST_DIR" + +echo -e "${YELLOW}Running bb64 tests...${NC}\n" + +# Check if bb64 binary exists +if [ ! -f "$BB64" ]; then + echo -e "${RED}Error: bb64 binary not found at $BB64${NC}" + echo "Please run ./build.sh first to build bb64" + exit 1 +fi + +if [ ! -x "$BB64" ]; then + echo -e "${RED}Error: bb64 binary is not executable${NC}" + exit 1 +fi + +echo "Using bb64 binary: $BB64" + +# Test 1: Version command with -v flag +echo "Test 1: Version command (-v flag)" +VERSION_OUTPUT=$("$BB64" -v 2>&1 || true) +# Version output should be just the version number +VERSION=$(echo "$VERSION_OUTPUT" | head -n 1) +if [[ "$VERSION" =~ ^[0-9]{4}\.[0-9]{4}\.[0-9]{4}$ ]]; then + print_test_result "Version format with -v flag (YYYY.MMDD.HHMM)" 0 +else + print_test_result "Version format with -v flag (YYYY.MMDD.HHMM)" 1 + echo " Expected: YYYY.MMDD.HHMM format, got: '$VERSION'" +fi + +# Test 2: Version command with 'version' argument +printf "\nTest 2: Version command (version argument)\n" +VERSION_OUTPUT2=$("$BB64" version 2>&1 || true) +# Version output should be just the version number +VERSION2=$(echo "$VERSION_OUTPUT2" | head -n 1) +if [[ "$VERSION2" =~ ^[0-9]{4}\.[0-9]{4}\.[0-9]{4}$ ]]; then + print_test_result "Version format with 'version' argument (YYYY.MMDD.HHMM)" 0 +else + print_test_result "Version format with 'version' argument (YYYY.MMDD.HHMM)" 1 + echo " Expected: YYYY.MMDD.HHMM format, got: '$VERSION2'" +fi + +# Test 3: Both version commands should return the same version +printf "\nTest 3: Version consistency\n" +if [ "$VERSION" = "$VERSION2" ]; then + print_test_result "Both -v and version return same version" 0 +else + print_test_result "Both -v and version return same version" 1 + echo " -v returned: '$VERSION'" + echo " version returned: '$VERSION2'" +fi + +# Test 4: Basic encoding test +echo -e "\nTest 4: Basic encoding test" +TEST_STRING="hello world" +ENCODED_OUTPUT=$("$BB64" -e <<< "$TEST_STRING" 2>&1 || true) +if [ -n "$ENCODED_OUTPUT" ]; then + print_test_result "Basic encoding produces output" 0 +else + print_test_result "Basic encoding produces output" 1 +fi + +# Test 5: Basic decoding test (using -d flag) +echo -e "\nTest 5: Basic decoding test" +# Encode "echo hello" and then decode it +ENCODED_ECHO=$(echo "echo hello" | "$BB64" -e) +if [ -n "$ENCODED_ECHO" ]; then + DECODED_OUTPUT=$("$BB64" -d "$ENCODED_ECHO" 2>&1 || true) + if [[ "$DECODED_OUTPUT" == *"echo hello"* ]]; then + print_test_result "Basic decoding works correctly" 0 + else + print_test_result "Basic decoding works correctly" 1 + echo " Expected to contain 'echo hello', got: '$DECODED_OUTPUT'" + fi +else + print_test_result "Basic decoding works correctly" 1 + echo " Failed to encode test string" +fi + +cleanup + +# Print summary +echo -e "\n${YELLOW}Test Summary:${NC}" +echo -e "Tests passed: ${GREEN}${TESTS_PASSED}${NC}" +echo -e "Tests failed: ${RED}${TESTS_FAILED}${NC}" + +if [ "$TESTS_FAILED" -eq 0 ]; then + echo -e "\n${GREEN}All tests passed!${NC}" + exit 0 +else + echo -e "\n${RED}Some tests failed!${NC}" + exit 1 +fi \ No newline at end of file