Skip to content

Commit e226285

Browse files
committed
Bypass interactive editor selection prompt when target scheme is provided
- when run with flag e.g. 'vscode, should not show this part [Pasted text]
1 parent 133dc78 commit e226285

2 files changed

Lines changed: 54 additions & 56 deletions

File tree

‎install.ps1‎

Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -58,24 +58,12 @@ Check-Editor "VSCodium" "codium" "vscodium"
5858
Check-Editor "Cursor" "cursor" "cursor"
5959
Check-Editor "Antigravity" "agy-ide" "agy"
6060

61-
Write-Host "`nHint: If your editor is installed but not listed, you might need to add its command to your PATH." -ForegroundColor Yellow
62-
Write-Host "Open your editor, open the Command Palette (Ctrl+Shift+P / Cmd+Shift+P), and find a command like: `"Shell Command: Install 'cursor' command in PATH`" (or 'agy-ide', etc.)." -ForegroundColor Yellow
63-
6461
if ($availableEditors.Count -eq 0) {
6562
Write-Host "Error: No supported editors found in your PATH." -ForegroundColor Red
6663
Pause
6764
exit 1
6865
}
6966

70-
Write-Host ""
71-
for ($i = 0; $i -lt $availableEditors.Count; $i++) {
72-
Write-Host "$($i + 1)) $($availableEditors[$i])"
73-
}
74-
if ($availableEditors.Count -gt 1) {
75-
Write-Host "a) All detected editors"
76-
}
77-
Write-Host "q) Quit`n"
78-
7967
$autoChoice = $null
8068
if ($targetScheme) {
8169
for ($i = 0; $i -lt $editorSchemes.Count; $i++) {
@@ -88,26 +76,37 @@ if ($targetScheme) {
8876

8977
if ($autoChoice) {
9078
$choice = $autoChoice.ToString()
91-
Write-Host "Automatically selected $($availableEditors[$autoChoice - 1]) based on current editor ($targetScheme)." -ForegroundColor Green
9279
} else {
93-
$choice = Read-Host "Select where to install CWC to"
94-
}
80+
Write-Host "`nHint: If your editor is installed but not listed, you might need to add its command to your PATH." -ForegroundColor Yellow
81+
Write-Host "Open your editor, open the Command Palette (Ctrl+Shift+P / Cmd+Shift+P), and find a command like: `"Shell Command: Install 'cursor' command in PATH`" (or 'agy-ide', etc.)." -ForegroundColor Yellow
9582

96-
if ($choice -eq 'q' -or $choice -eq 'Q') {
97-
Write-Host "Installation cancelled."
98-
Pause
99-
exit 0
100-
} elseif ($choice -eq 'a' -or $choice -eq 'A') {
101-
if ($availableEditors.Count -le 1) {
102-
Write-Host "Error: Invalid choice. Exiting." -ForegroundColor Red
103-
Pause
104-
exit 1
83+
Write-Host ""
84+
for ($i = 0; $i -lt $availableEditors.Count; $i++) {
85+
Write-Host "$($i + 1)) $($availableEditors[$i])"
10586
}
106-
} else {
107-
if ($choice -notmatch '^[0-9]+$' -or [int]$choice -lt 1 -or [int]$choice -gt $availableEditors.Count) {
108-
Write-Host "Error: Invalid choice. Exiting." -ForegroundColor Red
87+
if ($availableEditors.Count -gt 1) {
88+
Write-Host "a) All detected editors"
89+
}
90+
Write-Host "q) Quit`n"
91+
92+
$choice = Read-Host "Select where to install CWC to"
93+
94+
if ($choice -eq 'q' -or $choice -eq 'Q') {
95+
Write-Host "Installation cancelled."
10996
Pause
110-
exit 1
97+
exit 0
98+
} elseif ($choice -eq 'a' -or $choice -eq 'A') {
99+
if ($availableEditors.Count -le 1) {
100+
Write-Host "Error: Invalid choice. Exiting." -ForegroundColor Red
101+
Pause
102+
exit 1
103+
}
104+
} else {
105+
if ($choice -notmatch '^[0-9]+$' -or [int]$choice -lt 1 -or [int]$choice -gt $availableEditors.Count) {
106+
Write-Host "Error: Invalid choice. Exiting." -ForegroundColor Red
107+
Pause
108+
exit 1
109+
}
111110
}
112111
}
113112

‎install.sh‎

Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -70,25 +70,11 @@ check_editor "VSCodium" "codium" "vscodium"
7070
check_editor "Cursor" "cursor" "cursor"
7171
check_editor "Antigravity" "agy-ide" "agy"
7272

73-
echo ""
74-
echo "Hint: If your editor is installed but not listed, you might need to add its command to your PATH."
75-
echo "Open your editor, open the Command Palette (Ctrl+Shift+P / Cmd+Shift+P), and find a command like: \"Shell Command: Install 'cursor' command in PATH\" (or 'agy-ide', etc.)."
76-
7773
if [ ${#AVAILABLE_EDITORS[@]} -eq 0 ]; then
7874
echo "Error: No supported editors found in your PATH."
7975
exit 1
8076
fi
8177

82-
echo ""
83-
for i in "${!AVAILABLE_EDITORS[@]}"; do
84-
echo "$((i+1))) ${AVAILABLE_EDITORS[$i]}"
85-
done
86-
if [ ${#AVAILABLE_EDITORS[@]} -gt 1 ]; then
87-
echo "a) All detected editors"
88-
fi
89-
echo "q) Quit"
90-
echo ""
91-
9278
TARGET_SCHEME="$1"
9379
AUTO_CHOICE=""
9480

@@ -103,28 +89,41 @@ fi
10389

10490
if [ -n "$AUTO_CHOICE" ]; then
10591
choice="$AUTO_CHOICE"
106-
echo "Automatically selected ${AVAILABLE_EDITORS[$((choice-1))]} based on current editor ($TARGET_SCHEME)."
10792
else
93+
echo ""
94+
echo "Hint: If your editor is installed but not listed, you might need to add its command to your PATH."
95+
echo "Open your editor, open the Command Palette (Ctrl+Shift+P / Cmd+Shift+P), and find a command like: \"Shell Command: Install 'cursor' command in PATH\" (or 'agy-ide', etc.)."
96+
97+
echo ""
98+
for i in "${!AVAILABLE_EDITORS[@]}"; do
99+
echo "$((i+1))) ${AVAILABLE_EDITORS[$i]}"
100+
done
101+
if [ ${#AVAILABLE_EDITORS[@]} -gt 1 ]; then
102+
echo "a) All detected editors"
103+
fi
104+
echo "q) Quit"
105+
echo ""
106+
108107
# Handle interactive prompt even if script is piped via curl | bash
109108
if [ -c /dev/tty ]; then
110109
read -p "Select where to install CWC to: " choice < /dev/tty
111110
else
112111
read -p "Select where to install CWC to: " choice
113112
fi
114-
fi
115113

116-
if [[ "$choice" == "q" || "$choice" == "Q" ]]; then
117-
echo "Installation cancelled."
118-
exit 0
119-
elif [[ "$choice" == "a" || "$choice" == "A" ]]; then
120-
if [ ${#AVAILABLE_EDITORS[@]} -le 1 ]; then
121-
echo "Error: Invalid choice. Exiting."
122-
exit 1
123-
fi
124-
else
125-
if ! [[ "$choice" =~ ^[0-9]+$ ]] || [ "$choice" -lt 1 ] || [ "$choice" -gt "${#AVAILABLE_EDITORS[@]}" ]; then
126-
echo "Error: Invalid choice. Exiting."
127-
exit 1
114+
if [[ "$choice" == "q" || "$choice" == "Q" ]]; then
115+
echo "Installation cancelled."
116+
exit 0
117+
elif [[ "$choice" == "a" || "$choice" == "A" ]]; then
118+
if [ ${#AVAILABLE_EDITORS[@]} -le 1 ]; then
119+
echo "Error: Invalid choice. Exiting."
120+
exit 1
121+
fi
122+
else
123+
if ! [[ "$choice" =~ ^[0-9]+$ ]] || [ "$choice" -lt 1 ] || [ "$choice" -gt "${#AVAILABLE_EDITORS[@]}" ]; then
124+
echo "Error: Invalid choice. Exiting."
125+
exit 1
126+
fi
128127
fi
129128
fi
130129

0 commit comments

Comments
 (0)