#!/bin/bash
# Basic WLK Usage Example

echo "WLK Basic Usage Example"
echo "======================="
echo ""

# Setup
mkdir -p /tmp/wlk-example
cd /tmp/wlk-example

echo "1. Initialize repository"
wlk init
echo ""

echo "2. Create a simple file"
cat > hello.rs << 'EOF'
fn main() {
    println!("Hello, World!");
}
EOF
echo "   Created hello.rs"
echo ""

echo "3. Track the file"
wlk track hello.rs
echo ""

echo "4. View initial history"
wlk history hello.rs
echo ""

echo "5. Make a change"
cat > hello.rs << 'EOF'
fn main() {
    let name = "WLK";
    println!("Hello, {}!", name);
}
EOF
echo "   Modified hello.rs"
echo ""

echo "6. Create snapshot"
wlk snapshot hello.rs -m "Added name variable"
echo ""

echo "7. View updated history"
wlk history hello.rs
echo ""

echo "8. View history as tree"
wlk history hello.rs --tree
echo ""

echo "9. Rewind to previous version"
wlk rewind hello.rs
echo ""

echo "10. Check file content (reverted)"
cat hello.rs
echo ""

echo "11. Make different change (creates branch)"
cat > hello.rs << 'EOF'
fn main() {
    let greeting = "Greetings";
    println!("{}, World!", greeting);
}
EOF
wlk snapshot hello.rs -m "Alternative: greeting variable"
echo ""

echo "12. View branches"
wlk branches hello.rs
echo ""

echo "13. View branch tree"
wlk history hello.rs --tree
echo ""

echo "Cleanup"
cd /
rm -rf /tmp/wlk-example

echo ""
echo "Example complete!"
