Skip to content

Commit 77bd95d

Browse files
authored
Merge pull request #37 from mylee04/codex/fix-windows-version-and-update-output
Fix Windows version shortcut and add explicit all aliases
2 parents 4a5035b + b43fa62 commit 77bd95d

9 files changed

Lines changed: 236 additions & 35 deletions

File tree

.github/workflows/macos-test.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ jobs:
159159
UPDATE_OUTPUT="$(CODE_NOTIFY_LATEST_VERSION="$CURRENT_VERSION" cn update check)"
160160
echo "$UPDATE_OUTPUT"
161161
162-
if ! echo "$UPDATE_OUTPUT" | grep -q 'Already up to date'; then
162+
if ! echo "$UPDATE_OUTPUT" | grep -q 'Code-Notify is up to date'; then
163163
echo "ERROR: update check did not report the install as current"
164164
exit 1
165165
fi
@@ -176,7 +176,7 @@ jobs:
176176
UPDATE_OUTPUT="$(CODE_NOTIFY_LATEST_VERSION="$CURRENT_VERSION" cn update)"
177177
echo "$UPDATE_OUTPUT"
178178
179-
if ! echo "$UPDATE_OUTPUT" | grep -q 'Already up to date'; then
179+
if ! echo "$UPDATE_OUTPUT" | grep -q 'Code-Notify is up to date'; then
180180
echo "ERROR: update command did not skip reinstalling the current version"
181181
exit 1
182182
fi
@@ -190,7 +190,7 @@ jobs:
190190
export PATH="$HOME/.local/bin:$PATH"
191191
192192
# Enable
193-
cn on
193+
cn on all
194194
195195
# Check settings.json was created with hooks
196196
SETTINGS_FILE="$HOME/.claude/settings.json"
@@ -206,7 +206,7 @@ jobs:
206206
echo "OK: Notifications enabled, hooks configured"
207207
208208
# Disable
209-
cn off
209+
cn off all
210210
211211
if jq -e '.hooks' "$SETTINGS_FILE" > /dev/null 2>&1; then
212212
echo "ERROR: hooks not removed from settings"

.github/workflows/windows-test.yml

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,21 @@ jobs:
113113
run: |
114114
& "$env:USERPROFILE\.code-notify\bin\cn.ps1" version
115115
116+
- name: Test CLI commands (version shortcut)
117+
run: |
118+
$versionOutput = & "$env:USERPROFILE\.code-notify\bin\cn.ps1" -v | Out-String
119+
Write-Host $versionOutput
120+
121+
if ($versionOutput -match 'VERBOSE:') {
122+
Write-Host "ERROR: cn -v leaked PowerShell verbose import output" -ForegroundColor Red
123+
exit 1
124+
}
125+
126+
if ($versionOutput -notmatch 'code-notify version') {
127+
Write-Host "ERROR: cn -v did not resolve to the version command" -ForegroundColor Red
128+
exit 1
129+
}
130+
116131
- name: Test CLI commands (status)
117132
run: |
118133
& "$env:USERPROFILE\.code-notify\bin\cn.ps1" status
@@ -124,7 +139,7 @@ jobs:
124139
$updateOutput = & "$env:USERPROFILE\.code-notify\bin\cn.ps1" update check | Out-String
125140
Write-Host $updateOutput
126141
127-
if ($updateOutput -notmatch 'Already up to date') {
142+
if ($updateOutput -notmatch 'Code-Notify is up to date') {
128143
Write-Host "ERROR: update check did not report the install as current" -ForegroundColor Red
129144
exit 1
130145
}
@@ -141,7 +156,7 @@ jobs:
141156
$updateOutput = & "$env:USERPROFILE\.code-notify\bin\cn.ps1" update | Out-String
142157
Write-Host $updateOutput
143158
144-
if ($updateOutput -notmatch 'Already up to date') {
159+
if ($updateOutput -notmatch 'Code-Notify is up to date') {
145160
Write-Host "ERROR: update command did not skip reinstalling the current version" -ForegroundColor Red
146161
exit 1
147162
}
@@ -166,7 +181,7 @@ jobs:
166181
- name: Test enable/disable notifications
167182
run: |
168183
# Enable
169-
& "$env:USERPROFILE\.code-notify\bin\cn.ps1" on
184+
& "$env:USERPROFILE\.code-notify\bin\cn.ps1" on all
170185
171186
# Check settings.json was created with hooks
172187
$settingsFile = "$env:USERPROFILE\.claude\settings.json"
@@ -183,7 +198,7 @@ jobs:
183198
Write-Host "OK: Notifications enabled, hooks configured" -ForegroundColor Green
184199
185200
# Disable
186-
& "$env:USERPROFILE\.code-notify\bin\cn.ps1" off
201+
& "$env:USERPROFILE\.code-notify\bin\cn.ps1" off all
187202
188203
$settings = Get-Content $settingsFile -Raw | ConvertFrom-Json
189204
if ($settings.hooks) {

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,12 @@ curl -s https://raw.githubusercontent.com/mylee04/code-notify/main/docs/installa
9292
| Command | Description |
9393
| -------------------- | -------------------------------------------- |
9494
| `cn on` | Enable notifications for all detected tools |
95+
| `cn on all` | Explicit alias for enabling all detected tools |
9596
| `cn on claude` | Enable for Claude Code only |
9697
| `cn on codex` | Enable for Codex only |
9798
| `cn on gemini` | Enable for Gemini CLI only |
9899
| `cn off` | Disable notifications |
100+
| `cn off all` | Explicit alias for disabling all tools |
99101
| `cn test` | Send test notification |
100102
| `cn status` | Show current status |
101103
| `cn update` | Update code-notify |
@@ -108,6 +110,7 @@ curl -s https://raw.githubusercontent.com/mylee04/code-notify/main/docs/installa
108110
| `cnp on` | Enable for current project only |
109111

110112
When enabling project notifications with `cnp on`, Code-Notify warns if Claude project trust does not appear to be accepted yet.
113+
`all` is also accepted as an explicit alias for global commands such as `cn on all`, `cn off all`, and `cn status all`.
111114

112115
## How It Works
113116

lib/code-notify/commands/global.sh

Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -151,18 +151,31 @@ print_update_status() {
151151
local latest_version="$2"
152152
local comparison="$3"
153153

154-
info "Current version: $current_version"
155-
info "Latest release: $latest_version"
156-
157154
case "$comparison" in
158155
-1)
156+
info "Current version: $current_version"
159157
warning "Update available: $current_version -> $latest_version"
160158
;;
161159
0)
162-
success "Already up to date"
160+
info "Current version: $current_version"
161+
success "Code-Notify is up to date ($current_version)"
163162
;;
164163
1)
165-
info "Installed version is newer than the latest release"
164+
info "Current version: $current_version"
165+
info "Installed version is newer than the latest release ($latest_version)"
166+
;;
167+
esac
168+
}
169+
170+
normalize_tool_argument() {
171+
local tool="${1:-}"
172+
173+
case "$tool" in
174+
""|"all")
175+
printf '%s\n' ""
176+
;;
177+
*)
178+
printf '%s\n' "$tool"
166179
;;
167180
esac
168181
}
@@ -309,7 +322,8 @@ show_version() {
309322

310323
# Enable notifications globally
311324
enable_notifications_global() {
312-
local tool="${1:-}"
325+
local tool
326+
tool="$(normalize_tool_argument "${1:-}")"
313327

314328
header "${ROCKET} Enabling Notifications"
315329
echo ""
@@ -400,7 +414,8 @@ enable_single_tool() {
400414

401415
# Disable notifications globally
402416
disable_notifications_global() {
403-
local tool="${1:-}"
417+
local tool
418+
tool="$(normalize_tool_argument "${1:-}")"
404419

405420
header "${MUTE} Disabling Notifications"
406421
echo ""
@@ -462,6 +477,16 @@ disable_single_tool() {
462477

463478
# Show current status
464479
show_status() {
480+
local arg
481+
local check_updates_flag=""
482+
483+
for arg in "$@"; do
484+
if [[ "$arg" == "--check-updates" ]]; then
485+
check_updates_flag="yes"
486+
break
487+
fi
488+
done
489+
465490
header "${INFO} Code-Notify Status"
466491
echo ""
467492

@@ -576,7 +601,7 @@ show_status() {
576601
dim "code-notify version $VERSION"
577602

578603
# Check for updates if --check-updates flag is passed
579-
if [[ "$1" == "--check-updates" ]]; then
604+
if [[ -n "$check_updates_flag" ]]; then
580605
check_for_updates
581606
fi
582607
}

lib/code-notify/utils/help.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,13 @@ ${BOLD}USAGE:${RESET}
1717
1818
${BOLD}COMMANDS:${RESET}
1919
${GREEN}on${RESET} Enable notifications (all detected tools)
20+
${GREEN}on${RESET} all Enable notifications (explicit alias for all detected tools)
2021
${GREEN}on${RESET} <tool> Enable for specific tool (claude/codex/gemini)
2122
${GREEN}off${RESET} Disable notifications (all tools)
23+
${GREEN}off${RESET} all Disable notifications (explicit alias for all tools)
2224
${GREEN}off${RESET} <tool> Disable for specific tool
2325
${GREEN}status${RESET} Show status for all tools
26+
${GREEN}status${RESET} all Show status for all tools (explicit alias)
2427
${GREEN}test${RESET} Send a test notification
2528
${GREEN}update${RESET} [check] Update code-notify or check the latest release
2629
${GREEN}alerts${RESET} <cmd> Configure which events trigger alerts
@@ -69,9 +72,12 @@ ${BOLD}ALIASES:${RESET}
6972
7073
${BOLD}EXAMPLES:${RESET}
7174
cn on # Enable for all detected tools
75+
cn on all # Same as cn on
7276
cn on claude # Enable for Claude Code only
7377
cn off # Disable all
78+
cn off all # Same as cn off
7479
cn status # Show status for all tools
80+
cn status all # Same as cn status
7581
cn test # Send test notification
7682
cn update check # Check whether an update is needed and show the update command
7783
cn alerts # Show alert type config

scripts/install-windows.ps1

Lines changed: 49 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1071,19 +1071,25 @@ function Write-UpdateStatus {
10711071
[pscustomobject]$Status
10721072
)
10731073
1074-
Write-Output "[i] Current version: $($Status.CurrentVersion)"
1075-
10761074
if (-not $Status.LatestVersion) {
1075+
Write-Output "[i] Current version: $($Status.CurrentVersion)"
10771076
Write-Output "[!] Could not determine the latest release"
10781077
return
10791078
}
10801079
1081-
Write-Output "[i] Latest release: $($Status.LatestVersion)"
1082-
10831080
switch ($Status.Comparison) {
1084-
-1 { Write-Output "[!] Update available: $($Status.CurrentVersion) -> $($Status.LatestVersion)" }
1085-
0 { Write-Output "[OK] Already up to date" }
1086-
1 { Write-Output "[i] Installed version is newer than the latest release" }
1081+
-1 {
1082+
Write-Output "[i] Current version: $($Status.CurrentVersion)"
1083+
Write-Output "[!] Update available: $($Status.CurrentVersion) -> $($Status.LatestVersion)"
1084+
}
1085+
0 {
1086+
Write-Output "[i] Current version: $($Status.CurrentVersion)"
1087+
Write-Output "[OK] Code-Notify is up to date ($($Status.CurrentVersion))"
1088+
}
1089+
1 {
1090+
Write-Output "[i] Current version: $($Status.CurrentVersion)"
1091+
Write-Output "[i] Installed version is newer than the latest release ($($Status.LatestVersion))"
1092+
}
10871093
}
10881094
}
10891095
@@ -1157,9 +1163,9 @@ USAGE:
11571163
cnp <command> # Project command alias
11581164
11591165
COMMANDS:
1160-
on [tool] Enable notifications globally or for a specific tool
1161-
off [tool] Disable notifications globally or for a specific tool
1162-
status [tool] Show notification status
1166+
on [tool|all] Enable notifications globally or for a specific tool
1167+
off [tool|all] Disable notifications globally or for a specific tool
1168+
status [tool|all] Show notification status
11631169
test Send a test notification
11641170
update [check] Update code-notify or check the latest release
11651171
voice on Enable voice notifications
@@ -1189,7 +1195,9 @@ PROJECT COMMANDS:
11891195
11901196
EXAMPLES:
11911197
code-notify on # Enable Claude notifications
1198+
cn on all # Enable all detected tools
11921199
cn on codex # Enable Codex notifications
1200+
cn off all # Disable all tools
11931201
cn off gemini # Disable Gemini notifications
11941202
cnp on # Enable Claude project notifications
11951203
cn test # Send test notification
@@ -1678,8 +1686,21 @@ exit 0
16781686
$cliWrapper = @'
16791687
# Code-Notify CLI wrapper
16801688
param([Parameter(ValueFromRemainingArguments)][string[]]$Args)
1681-
Import-Module "$env:USERPROFILE\.code-notify\lib\CodeNotify.psm1" -Force
1682-
Invoke-CodeNotify @Args
1689+
$requestedVersionShortcut = $false
1690+
$invocationLine = [string]$MyInvocation.Line
1691+
if ($Args.Count -eq 1 -and @('version', '-v', '--version') -contains $Args[0]) {
1692+
$requestedVersionShortcut = $true
1693+
} elseif ($Args.Count -eq 0 -and $invocationLine -match '(^|\s)-v($|\s)') {
1694+
$requestedVersionShortcut = $true
1695+
} elseif ($Args.Count -eq 0 -and $invocationLine -match '(^|\s)--version($|\s)') {
1696+
$requestedVersionShortcut = $true
1697+
}
1698+
Import-Module "$env:USERPROFILE\.code-notify\lib\CodeNotify.psm1" -Force -Verbose:$false
1699+
if ($requestedVersionShortcut) {
1700+
Invoke-CodeNotify "version"
1701+
} else {
1702+
Invoke-CodeNotify @Args
1703+
}
16831704
'@
16841705

16851706
$cliWrapper | Set-Content "$InstallDir\bin\code-notify.ps1" -Encoding UTF8
@@ -1688,16 +1709,29 @@ Invoke-CodeNotify @Args
16881709
$cnWrapper = @'
16891710
# cn - Code-Notify shortcut
16901711
param([Parameter(ValueFromRemainingArguments)][string[]]$Args)
1691-
Import-Module "$env:USERPROFILE\.code-notify\lib\CodeNotify.psm1" -Force
1692-
Invoke-CodeNotify @Args
1712+
$requestedVersionShortcut = $false
1713+
$invocationLine = [string]$MyInvocation.Line
1714+
if ($Args.Count -eq 1 -and @('version', '-v', '--version') -contains $Args[0]) {
1715+
$requestedVersionShortcut = $true
1716+
} elseif ($Args.Count -eq 0 -and $invocationLine -match '(^|\s)-v($|\s)') {
1717+
$requestedVersionShortcut = $true
1718+
} elseif ($Args.Count -eq 0 -and $invocationLine -match '(^|\s)--version($|\s)') {
1719+
$requestedVersionShortcut = $true
1720+
}
1721+
Import-Module "$env:USERPROFILE\.code-notify\lib\CodeNotify.psm1" -Force -Verbose:$false
1722+
if ($requestedVersionShortcut) {
1723+
Invoke-CodeNotify "version"
1724+
} else {
1725+
Invoke-CodeNotify @Args
1726+
}
16931727
'@
16941728
$cnWrapper | Set-Content "$InstallDir\bin\cn.ps1" -Encoding UTF8
16951729

16961730
# Create cnp alias (project commands)
16971731
$cnpWrapper = @'
16981732
# cnp - Code-Notify Project shortcut
16991733
param([Parameter(ValueFromRemainingArguments)][string[]]$Args)
1700-
Import-Module "$env:USERPROFILE\.code-notify\lib\CodeNotify.psm1" -Force
1734+
Import-Module "$env:USERPROFILE\.code-notify\lib\CodeNotify.psm1" -Force -Verbose:$false
17011735
Invoke-CodeNotify "project" @Args
17021736
'@
17031737
$cnpWrapper | Set-Content "$InstallDir\bin\cnp.ps1" -Encoding UTF8

scripts/run_tests.sh

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,15 +104,15 @@ fi
104104

105105
# Test 8: update check command works
106106
test_start "update check command"
107-
if CODE_NOTIFY_INSTALL_METHOD=script CODE_NOTIFY_LATEST_VERSION="$CURRENT_VERSION" ./bin/code-notify update check 2>&1 | grep -q "Already up to date"; then
107+
if CODE_NOTIFY_INSTALL_METHOD=script CODE_NOTIFY_LATEST_VERSION="$CURRENT_VERSION" ./bin/code-notify update check 2>&1 | grep -q "Code-Notify is up to date"; then
108108
test_pass
109109
else
110110
test_fail "update check command failed"
111111
fi
112112

113113
# Test 9: update command skips reinstalling current versions
114114
test_start "no-op update command"
115-
if CODE_NOTIFY_INSTALL_METHOD=script CODE_NOTIFY_LATEST_VERSION="$CURRENT_VERSION" ./bin/code-notify update 2>&1 | grep -q "Already up to date"; then
115+
if CODE_NOTIFY_INSTALL_METHOD=script CODE_NOTIFY_LATEST_VERSION="$CURRENT_VERSION" ./bin/code-notify update 2>&1 | grep -q "Code-Notify is up to date"; then
116116
test_pass
117117
else
118118
test_fail "update command did not skip reinstalling the current version"
@@ -126,6 +126,14 @@ else
126126
test_fail "project trust warning behavior failed"
127127
fi
128128

129+
# Test 11: explicit all aliases map to global behavior
130+
test_start "all tool aliases"
131+
if bash tests/test-all-alias.sh >/dev/null 2>&1; then
132+
test_pass
133+
else
134+
test_fail "all aliases failed"
135+
fi
136+
129137
# Summary
130138
echo ""
131139
echo "Test Summary:"

0 commit comments

Comments
 (0)