refactor(shell): use powershell and bash package names
This commit is contained in:
1 parent
9a2a606410
commit
6a0c4abb65
11 files changed
+108
-87
No files matched your search
@@ -1,7 +1,7 @@
|
||||
function Read-InstallPlatform {
|
||||
param([string]$Platform)
|
||||
if ($Platform) { return $Platform }
|
||||
return Read-InteractiveSingle -Title 'Select shell' -Names @('PowerShell','Bash') -Values @('Windows','Linux')
|
||||
function Read-InstallShell {
|
||||
param([string]$Shell)
|
||||
if ($Shell) { return $Shell }
|
||||
return Read-InteractiveSingle -Title 'Select shell' -Names @('PowerShell','Bash') -Values @('PowerShell','Bash')
|
||||
}
|
||||
function Read-InstallClient {
|
||||
param([string]$Client)
|
||||
@@ -13,14 +13,14 @@ function Read-InteractiveSingle {
|
||||
param([string]$Title,[string[]]$Names,[string[]]$Values)
|
||||
if ([Console]::IsInputRedirected -or $env:CI -eq 'true' -or $env:AI_CONFIG_NO_INTERACTIVE -eq '1') {
|
||||
Write-Host $Title; for($i=0;$i -lt $Names.Count;$i++){ Write-Host ('{0}) {1}' -f ($i+1),$Names[$i]) }
|
||||
do { $answer=Read-Host 'Selection' } while($answer -notmatch ('^[1-{0}]$' -f $Names.Count)); return $Values[[int]$answer-1]
|
||||
do { $answer=Read-Host 'Selection'; if ($null -eq $answer -or ([Console]::IsInputRedirected -and $answer -eq '')) { throw 'Selection input ended before a choice was provided.' } } while($answer -notmatch ('^[1-{0}]$' -f $Names.Count)); return $Values[[int]$answer-1]
|
||||
}
|
||||
$index=0
|
||||
while($true) {
|
||||
Clear-InteractiveScreen; Write-Host $Title
|
||||
for($i=0;$i -lt $Names.Count;$i++){ $prefix=if($i -eq $index){'>'}else{' '}; if($i -eq $index -and $env:NO_COLOR -ne '1'){Write-Host ('{0} {1}' -f $prefix,$Names[$i]) -ForegroundColor Cyan}else{Write-Host ('{0} {1}' -f $prefix,$Names[$i])} }
|
||||
Write-Host 'Up/Down Navigate Enter Confirm'; $key=[Console]::ReadKey($true)
|
||||
if($key.Key -eq 'Up'){ $index=($index+$Names.Count-1)%$Names.Count } elseif($key.Key -eq 'Down'){ $index=($index+1)%$Names.Count } elseif($key.Key -eq 'Enter'){ Clear-InteractiveScreen; return $Values[$index] }
|
||||
if($key.Key -eq 'UpArrow'){ $index=($index+$Names.Count-1)%$Names.Count } elseif($key.Key -eq 'DownArrow'){ $index=($index+1)%$Names.Count } elseif($key.Key -eq 'Enter'){ Clear-InteractiveScreen; return $Values[$index] }
|
||||
}
|
||||
}
|
||||
function Get-InstallDestinations {
|
||||
@@ -28,8 +28,8 @@ function Get-InstallDestinations {
|
||||
$destinations=@(); if($Client -in @('Codex','Both')){$destinations+=Join-Path $HomePath '.codex'}; if($Client -in @('Claude','Both')){$destinations+=Join-Path $HomePath '.claude'}; return $destinations
|
||||
}
|
||||
function Get-InstallTargets {
|
||||
param([Parameter(Mandatory=$true)][string]$Generated,[Parameter(Mandatory=$true)][string]$HomePath,[Parameter(Mandatory=$true)][string]$Platform,[ValidateSet('Codex','Claude','Both')][Parameter(Mandatory=$true)][string]$Client)
|
||||
$targets=@(); if($Client -in @('Codex','Both')){$targets+=@{Source=(Join-Path $Generated "codex-$Platform");Destination=(Join-Path $HomePath '.codex')};$targets+=@{Source=(Join-Path $Generated "codex-$Platform/skills");Destination=(Join-Path $HomePath '.agents/skills')}}; if($Client -in @('Claude','Both')){$targets+=@{Source=(Join-Path $Generated "claude-$Platform");Destination=(Join-Path $HomePath '.claude')};}; return $targets
|
||||
param([Parameter(Mandatory=$true)][string]$Generated,[Parameter(Mandatory=$true)][string]$HomePath,[Parameter(Mandatory=$true)][string]$Shell,[ValidateSet('Codex','Claude','Both')][Parameter(Mandatory=$true)][string]$Client)
|
||||
$targets=@(); if($Client -in @('Codex','Both')){$targets+=@{Source=(Join-Path $Generated "codex-$($Shell.ToLowerInvariant())");Destination=(Join-Path $HomePath '.codex')};$targets+=@{Source=(Join-Path $Generated "codex-$($Shell.ToLowerInvariant())/skills");Destination=(Join-Path $HomePath '.agents/skills')}}; if($Client -in @('Claude','Both')){$targets+=@{Source=(Join-Path $Generated "claude-$($Shell.ToLowerInvariant())");Destination=(Join-Path $HomePath '.claude')};}; return $targets
|
||||
}
|
||||
function Test-AnyManifestPresent { param([Parameter(Mandatory=$true)][string[]]$Destinations); return [bool](@($Destinations|Where-Object{Test-Path(Get-ManagedManifestPath $_)}).Count) }
|
||||
function Test-AllManifestsPresent { param([Parameter(Mandatory=$true)][string[]]$Destinations); return [bool](@($Destinations|Where-Object{-not(Test-Path(Get-ManagedManifestPath $_))}).Count -eq 0) }
|
||||
@@ -1,15 +1,15 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
read_install_platform() {
|
||||
local platform=$1
|
||||
if [ -n "$platform" ]; then
|
||||
case "$platform" in
|
||||
windows|Windows) printf 'windows\n'; return 0 ;;
|
||||
linux|Linux) printf 'linux\n'; return 0 ;;
|
||||
*) printf 'Unknown --platform value: %s (expected windows or linux)\n' "$platform" >&2; return 1 ;;
|
||||
read_install_shell() {
|
||||
local shell=$1
|
||||
if [ -n "$shell" ]; then
|
||||
case "$shell" in
|
||||
powershell|PowerShell) printf 'powershell\n'; return 0 ;;
|
||||
bash|Bash) printf 'bash\n'; return 0 ;;
|
||||
*) printf 'Unknown --shell value: %s (expected powershell or bash)\n' "$shell" >&2; return 1 ;;
|
||||
esac
|
||||
fi
|
||||
read_single_selection 'Select shell' 'PowerShell' 'windows' 'Bash' 'linux'
|
||||
read_single_selection 'Select shell' 'PowerShell' 'powershell' 'Bash' 'bash'
|
||||
}
|
||||
|
||||
read_install_client() {
|
||||
@@ -25,12 +25,30 @@ read_install_client() {
|
||||
read_single_selection 'Select client' 'Codex' 'codex' 'Claude' 'claude' 'Both' 'both'
|
||||
}
|
||||
|
||||
clear_interactive() { [ -t 0 ] && [ "${CI:-}" != true ] && [ "${AI_CONFIG_NO_INTERACTIVE:-}" != 1 ] && printf '\033[2J\033[H'; }
|
||||
clear_interactive() { [ -t 0 ] && [ "${CI:-}" != true ] && [ "${AI_CONFIG_NO_INTERACTIVE:-}" != 1 ] && printf '\033[2J\033[H' >&2; }
|
||||
read_single_selection() {
|
||||
local title=$1; shift; local labels=() values=() label value index=0 key
|
||||
while [ $# -gt 0 ]; do labels+=("$1"); values+=("$2"); shift 2; done
|
||||
if [ ! -t 0 ] || [ "${CI:-}" = true ] || [ "${AI_CONFIG_NO_INTERACTIVE:-}" = 1 ]; then printf '%s\n' "$title" >&2; for ((index=0;index<${#labels[@]};index++)); do printf '%d) %s\n' "$((index+1))" "${labels[$index]}" >&2; done; while read -r -p 'Selection ' value; do [[ "$value" =~ ^[1-9][0-9]*$ ]] && [ "$value" -le "${#labels[@]}" ] && { printf '%s\n' "${values[$((value-1))]}"; return; }; done; return 1; fi
|
||||
local selected=0; while :; do clear_interactive; printf '%s\n' "$title"; for ((index=0;index<${#labels[@]};index++)); do [ "$index" -eq "$selected" ] && printf '> %s\n' "${labels[$index]}" || printf ' %s\n' "${labels[$index]}"; done; printf '↑/↓ Navigate Enter Confirm\n'; IFS= read -rsn1 key || return 1; case "$key" in $'\x1b') read -rsn2 key; case "$key" in '[A') selected=$(( (selected+${#labels[@]}-1)%${#labels[@]} ));; '[B') selected=$(( (selected+1)%${#labels[@]} ));; esac;; '') clear_interactive; printf '%s\n' "${values[$selected]}"; return;; esac; done
|
||||
local selected=0
|
||||
while :; do
|
||||
clear_interactive
|
||||
printf '%s\n' "$title" >&2
|
||||
for ((index=0;index<${#labels[@]};index++)); do
|
||||
if [ "$index" -eq "$selected" ]; then printf '> %s\n' "${labels[$index]}" >&2; else printf ' %s\n' "${labels[$index]}" >&2; fi
|
||||
done
|
||||
printf 'Up/Down Navigate Enter Confirm\n' >&2
|
||||
IFS= read -rsn1 key || return 1
|
||||
case "$key" in
|
||||
$'\x1b')
|
||||
read -rsn2 key || return 1
|
||||
case "$key" in
|
||||
'[A') selected=$(( (selected+${#labels[@]}-1)%${#labels[@]} ));;
|
||||
'[B') selected=$(( (selected+1)%${#labels[@]} ));;
|
||||
esac;;
|
||||
'') clear_interactive; printf '%s\n' "${values[$selected]}"; return;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
# get_install_destinations <home> <client> -- prints one destination per line
|
||||
@@ -40,16 +58,16 @@ get_install_destinations() {
|
||||
case "$client" in claude|both) printf '%s/.claude\n' "$home_path" ;; esac
|
||||
}
|
||||
|
||||
# get_install_targets <generated> <home> <platform> <client> -- prints "source|dest" per line
|
||||
# get_install_targets <generated> <home> <shell> <client> -- prints "source|dest" per line
|
||||
get_install_targets() {
|
||||
local generated=$1 home_path=$2 platform=$3 client=$4
|
||||
local generated=$1 home_path=$2 shell=$3 client=$4
|
||||
case "$client" in
|
||||
codex|both)
|
||||
printf '%s/codex-%s|%s/.codex\n' "$generated" "$platform" "$home_path"
|
||||
printf '%s/codex-%s/skills|%s/.agents/skills\n' "$generated" "$platform" "$home_path"
|
||||
printf '%s/codex-%s|%s/.codex\n' "$generated" "$shell" "$home_path"
|
||||
printf '%s/codex-%s/skills|%s/.agents/skills\n' "$generated" "$shell" "$home_path"
|
||||
;;
|
||||
esac
|
||||
case "$client" in claude|both) printf '%s/claude-%s|%s/.claude\n' "$generated" "$platform" "$home_path" ;; esac
|
||||
case "$client" in claude|both) printf '%s/claude-%s|%s/.claude\n' "$generated" "$shell" "$home_path" ;; esac
|
||||
}
|
||||
|
||||
# any_manifest_present <destination>... -- true (0) if at least one has a manifest
|
||||
|
||||
Reference in new issue
Block a user