Skip to content

Commit 8a0b250

Browse files
committed
Add cross-platform uninstallation scripts, fix install.ps1 color output
1 parent 173f79e commit 8a0b250

File tree

4 files changed

+217
-15
lines changed

4 files changed

+217
-15
lines changed

README.md

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ It supports both application log files and Docker container logs, runs entirely
3737

3838
I built **shepai** because I genuinely dislike debugging logs in the terminal.
3939

40-
Modern application logs are no longer simple strings — theyre often deeply nested JSON, long stack traces, or structured logs that wrap across multiple lines. In a terminal, this quickly becomes painful.
40+
Modern application logs are no longer simple strings — they're often deeply nested JSON, long stack traces, or structured logs that wrap across multiple lines. In a terminal, this quickly becomes painful.
4141

4242
I wanted a way to **see logs the way they deserve to be seen** — structured, searchable, expandable, and persistent on screen — without introducing heavy log infrastructure or changing application code.
4343

@@ -71,8 +71,6 @@ Choose the installation method for your operating system:
7171

7272
#### macOS & Linux
7373

74-
Run the automated installation script:
75-
7674
```bash
7775
curl -fsSL https://raw.githubusercontent.com/arifszn/shepai/main/install.sh | bash
7876
```
@@ -89,8 +87,6 @@ shepai --version
8987

9088
##### Option 1: PowerShell Script (Recommended)
9189

92-
Run the automated installation script in PowerShell:
93-
9490
```powershell
9591
irm https://raw.githubusercontent.com/arifszn/shepai/main/install.ps1 | iex
9692
```
@@ -117,6 +113,24 @@ If you prefer to install manually:
117113

118114
> **Note for Option 2:** For system-wide access, add the extracted directory to your PATH environment variable.
119115
116+
### Uninstallation
117+
118+
If you need to remove shepai from your system:
119+
120+
#### macOS & Linux
121+
122+
```bash
123+
curl -fsSL https://raw.githubusercontent.com/arifszn/shepai/main/uninstall.sh | bash
124+
```
125+
126+
---
127+
128+
#### Windows
129+
130+
```powershell
131+
irm https://raw.githubusercontent.com/arifszn/shepai/main/uninstall.ps1 | iex
132+
```
133+
120134
### Usage
121135

122136
#### File Logs

install.ps1

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,31 @@ $REPO = "arifszn/shepai"
1111
$BINARY_NAME = "shepai.exe"
1212

1313
# Color output functions
14-
function Write-ColorOutput($ForegroundColor) {
14+
function Write-ColorOutput {
15+
param(
16+
[string]$ForegroundColor,
17+
[string]$Message
18+
)
1519
$fc = $host.UI.RawUI.ForegroundColor
1620
$host.UI.RawUI.ForegroundColor = $ForegroundColor
17-
if ($args) {
18-
Write-Output $args
19-
}
21+
Write-Host $Message
2022
$host.UI.RawUI.ForegroundColor = $fc
2123
}
2224

23-
function Write-Success { Write-ColorOutput Green $args }
24-
function Write-Error-Message { Write-ColorOutput Red $args }
25-
function Write-Warning-Message { Write-ColorOutput Yellow $args }
25+
function Write-Success {
26+
param([string]$Message)
27+
Write-ColorOutput -ForegroundColor "Green" -Message $Message
28+
}
29+
30+
function Write-Error-Message {
31+
param([string]$Message)
32+
Write-ColorOutput -ForegroundColor "Red" -Message $Message
33+
}
34+
35+
function Write-Warning-Message {
36+
param([string]$Message)
37+
Write-ColorOutput -ForegroundColor "Yellow" -Message $Message
38+
}
2639

2740
# Detect architecture
2841
function Get-Platform {
@@ -144,7 +157,7 @@ function Install-Shepai {
144157
$targetPath = Join-Path $InstallDir $BINARY_NAME
145158
Copy-Item -Path $binaryPath -Destination $targetPath -Force
146159

147-
Write-Success " Successfully installed shepai to $targetPath"
160+
Write-Success "[OK] Successfully installed shepai to $targetPath"
148161

149162
# Add to PATH if not already present
150163
$userPath = [System.Environment]::GetEnvironmentVariable("Path", "User")
@@ -155,11 +168,11 @@ function Install-Shepai {
155168
"$userPath;$InstallDir",
156169
"User"
157170
)
158-
Write-Success " Added to PATH. Please restart your terminal for changes to take effect."
171+
Write-Success "[OK] Added to PATH. Please restart your terminal for changes to take effect."
159172
}
160173

161174
# Verify installation
162-
Write-Success " Installation complete!"
175+
Write-Success "[OK] Installation complete!"
163176
Write-Success "Run 'shepai --help' to get started (restart your terminal first)"
164177
}
165178
finally {

uninstall.ps1

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
# PowerShell uninstallation script for shepai on Windows
2+
3+
param(
4+
[string]$InstallDir = "$env:LOCALAPPDATA\Programs\shepai"
5+
)
6+
7+
$ErrorActionPreference = "Stop"
8+
9+
# Configuration
10+
$BINARY_NAME = "shepai.exe"
11+
12+
# Color output functions
13+
function Write-ColorOutput {
14+
param(
15+
[string]$ForegroundColor,
16+
[string]$Message
17+
)
18+
$fc = $host.UI.RawUI.ForegroundColor
19+
$host.UI.RawUI.ForegroundColor = $ForegroundColor
20+
Write-Host $Message
21+
$host.UI.RawUI.ForegroundColor = $fc
22+
}
23+
24+
function Write-Success {
25+
param([string]$Message)
26+
Write-ColorOutput -ForegroundColor "Green" -Message $Message
27+
}
28+
29+
function Write-Error-Message {
30+
param([string]$Message)
31+
Write-ColorOutput -ForegroundColor "Red" -Message $Message
32+
}
33+
34+
function Write-Warning-Message {
35+
param([string]$Message)
36+
Write-ColorOutput -ForegroundColor "Yellow" -Message $Message
37+
}
38+
39+
# Uninstall shepai
40+
function Uninstall-Shepai {
41+
$targetPath = Join-Path $InstallDir $BINARY_NAME
42+
43+
# Check if shepai is installed
44+
if (-not (Test-Path $InstallDir)) {
45+
Write-Warning-Message "shepai installation directory not found: $InstallDir"
46+
Write-Warning-Message "shepai may not be installed or was installed to a different location"
47+
return
48+
}
49+
50+
if (-not (Test-Path $targetPath)) {
51+
Write-Warning-Message "shepai binary not found: $targetPath"
52+
Write-Warning-Message "shepai may not be installed or was installed to a different location"
53+
}
54+
55+
# Remove installation directory
56+
try {
57+
Write-Warning-Message "Removing shepai from $InstallDir..."
58+
Remove-Item -Path $InstallDir -Recurse -Force -ErrorAction Stop
59+
Write-Success "[OK] Removed shepai installation directory"
60+
}
61+
catch {
62+
Write-Error-Message "Error: Failed to remove installation directory"
63+
Write-Error-Message $_.Exception.Message
64+
exit 1
65+
}
66+
67+
# Remove from PATH
68+
try {
69+
$userPath = [System.Environment]::GetEnvironmentVariable("Path", "User")
70+
71+
if ($userPath -like "*$InstallDir*") {
72+
Write-Warning-Message "Removing $InstallDir from user PATH..."
73+
74+
# Split path entries, filter out shepai directory, and rejoin
75+
$pathEntries = $userPath -split ';'
76+
$newPathEntries = $pathEntries | Where-Object { $_ -ne $InstallDir -and $_ -notlike '*shepai*' }
77+
$newPath = $newPathEntries -join ';'
78+
79+
[System.Environment]::SetEnvironmentVariable("Path", $newPath, "User")
80+
Write-Success "[OK] Removed from PATH. Please restart your terminal for changes to take effect."
81+
}
82+
else {
83+
Write-Warning-Message "shepai directory not found in PATH"
84+
}
85+
}
86+
catch {
87+
Write-Error-Message "Warning: Failed to update PATH"
88+
Write-Error-Message $_.Exception.Message
89+
}
90+
91+
Write-Success "[OK] Uninstallation complete!"
92+
Write-Success "shepai has been removed from your system"
93+
}
94+
95+
# Main
96+
Write-Success "Uninstalling shepai..."
97+
Uninstall-Shepai

uninstall.sh

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
# Colors for output
6+
RED='\033[0;31m'
7+
GREEN='\033[0;32m'
8+
YELLOW='\033[1;33m'
9+
NC='\033[0m' # No Color
10+
11+
# Configuration
12+
BINARY_NAME="shepai"
13+
INSTALL_DIR="/usr/local/bin"
14+
BINARY_PATH="$INSTALL_DIR/$BINARY_NAME"
15+
16+
# Uninstall function
17+
uninstall() {
18+
echo -e "${YELLOW}Uninstalling shepai...${NC}"
19+
20+
# Check if shepai is installed
21+
if [ ! -f "$BINARY_PATH" ]; then
22+
echo -e "${YELLOW}Warning: shepai not found at $BINARY_PATH${NC}"
23+
echo -e "${YELLOW}shepai may not be installed or was installed to a different location${NC}"
24+
25+
# Check if it exists in PATH
26+
if command -v "$BINARY_NAME" >/dev/null 2>&1; then
27+
FOUND_PATH=$(which "$BINARY_NAME")
28+
echo -e "${YELLOW}Found shepai at: $FOUND_PATH${NC}"
29+
30+
# Ask user if they want to remove this instead
31+
read -p "Do you want to remove this installation? (y/N) " -n 1 -r
32+
echo
33+
if [[ $REPLY =~ ^[Yy]$ ]]; then
34+
BINARY_PATH="$FOUND_PATH"
35+
else
36+
echo -e "${YELLOW}Uninstallation cancelled${NC}"
37+
exit 0
38+
fi
39+
else
40+
echo -e "${GREEN}shepai does not appear to be installed${NC}"
41+
exit 0
42+
fi
43+
fi
44+
45+
# Remove binary (requires sudo if in /usr/local/bin)
46+
if [ -w "$(dirname "$BINARY_PATH")" ]; then
47+
# Directory is writable, no sudo needed
48+
echo -e "${YELLOW}Removing $BINARY_PATH...${NC}"
49+
rm -f "$BINARY_PATH"
50+
else
51+
# Directory requires elevated permissions
52+
echo -e "${YELLOW}Removing $BINARY_PATH (requires sudo)...${NC}"
53+
if sudo rm -f "$BINARY_PATH"; then
54+
echo -e "${GREEN}✓ Successfully removed shepai from $BINARY_PATH${NC}"
55+
else
56+
echo -e "${RED}Error: Failed to remove binary${NC}"
57+
exit 1
58+
fi
59+
fi
60+
61+
# Verify removal
62+
if command -v "$BINARY_NAME" >/dev/null 2>&1; then
63+
echo -e "${YELLOW}Warning: shepai is still found in PATH${NC}"
64+
echo -e "${YELLOW}Location: $(which "$BINARY_NAME")${NC}"
65+
echo -e "${YELLOW}You may have multiple installations${NC}"
66+
else
67+
echo -e "${GREEN}✓ Uninstallation complete!${NC}"
68+
echo -e "${GREEN}shepai has been removed from your system${NC}"
69+
fi
70+
}
71+
72+
# Main
73+
main() {
74+
echo -e "${GREEN}Starting shepai uninstallation...${NC}"
75+
uninstall
76+
}
77+
78+
main "$@"

0 commit comments

Comments
 (0)