spacehub

surshar / claude-code

Claude Code is an agentic coding tool that lives in your terminal, understands your codebase, and helps you code faster by executing routine tasks, explaining complex code, and handling git workflows - all through natural language commands.

Built by Anthropic · github.com/anthropics

PowerShell parameter improvementsBrowse files
Kurt Carpenter authored on Jul 3, 2025 parent 545d78c · commit c93c724eeb65
1 changed file+14 -16compared with 545d78c
MScript/run_devcontainer_claude_code.ps1
@@ -1,4 +1,4 @@
1-<#
1+<#
22 .SYNOPSIS
33 Automates the setup and connection to a DevContainer environment using either Docker or Podman on Windows.
44
@@ -25,6 +25,7 @@
2525 └── Script/
2626 └── run_devcontainer_claude_code.ps1
2727 #>
28+
2829 [CmdletBinding()]
2930 param(
3031 [Parameter(Mandatory=$true)]
@@ -43,7 +44,7 @@
4344 # --- Step 1a: Initialize Podman machine ---
4445 Write-Host "Initializing Podman machine 'claudeVM'..."
4546 try {
46- podman machine init claudeVM
47+ & podman machine init claudeVM
4748 Write-Host "Podman machine 'claudeVM' initialized or already exists."
4849 } catch {
4950 Write-Error "Failed to initialize Podman machine: $($_.Exception.Message)"
@@ -53,7 +54,7 @@
5354 # --- Step 1b: Start Podman machine ---
5455 Write-Host "Starting Podman machine 'claudeVM'..."
5556 try {
56- podman machine start claudeVM -q
57+ & podman machine start claudeVM -q
5758 Write-Host "Podman machine started or already running."
5859 } catch {
5960 Write-Error "Failed to start Podman machine: $($_.Exception.Message)"
@@ -63,7 +64,7 @@
6364 # --- Step 2: Set default connection ---
6465 Write-Host "Setting default Podman connection to 'claudeVM'..."
6566 try {
66- podman system connection default claudeVM
67+ & podman system connection default claudeVM
6768 Write-Host "Default connection set."
6869 } catch {
6970 Write-Warning "Failed to set default Podman connection (may be already set or machine issue): $($_.Exception.Message)"
@@ -87,11 +88,11 @@
8788 # --- Step 3: Bring up DevContainer ---
8889 Write-Host "Bringing up DevContainer in the current folder..."
8990 try {
90- $devcontainerUpCommand = "devcontainer up --workspace-folder ."
91+ $arguments = @('up', '--workspace-folder', '.')
9192 if ($Backend -eq 'podman') {
92- $devcontainerUpCommand += " --docker-path podman"
93+ $arguments += '--docker-path', 'podman'
9394 }
94- Invoke-Expression $devcontainerUpCommand
95+ & devcontainer @arguments
9596 Write-Host "DevContainer startup process completed."
9697 } catch {
9798 Write-Error "Failed to bring up DevContainer: $($_.Exception.Message)"
@@ -102,12 +103,11 @@
102103 Write-Host "Finding the DevContainer ID..."
103104 $currentFolder = (Get-Location).Path
104105
105-$psCommand = "$($Backend) ps --filter ""label=devcontainer.local_folder=$currentFolder"" --format ""{{.ID}}"""
106-
107106 try {
108- $containerId = $(Invoke-Expression $psCommand).Trim()
107+ $containerId = (& $Backend ps --filter "label=devcontainer.local_folder=$currentFolder" --format '{{.ID}}').Trim()
109108 } catch {
110- Write-Error "Failed to get container ID (Command: $psCommand): $($_.Exception.Message)"
109+ $displayCommand = "$Backend ps --filter `"label=devcontainer.local_folder=$currentFolder`" --format '{{.ID}}'"
110+ Write-Error "Failed to get container ID (Command: $displayCommand): $($_.Exception.Message)"
111111 exit 1
112112 }
113113
@@ -121,13 +121,11 @@
121121 # --- Step 5 & 6: Execute command and enter interactive shell inside container ---
122122 Write-Host "Executing 'claude' command and then starting zsh session inside container $($containerId)..."
123123 try {
124- $execCommand = "$($Backend) exec -it $containerId zsh -c 'claude; exec zsh'"
125- Invoke-Expression $execCommand
126-
124+ & $Backend exec -it $containerId zsh -c 'claude; exec zsh'
127125 Write-Host "Interactive session ended."
128-
129126 } catch {
130- Write-Error "Failed to execute command inside container (Command: $execCommand): $($_.Exception.Message)"
127+ $displayCommand = "$Backend exec -it $containerId zsh -c 'claude; exec zsh'"
128+ Write-Error "Failed to execute command inside container (Command: $displayCommand): $($_.Exception.Message)"
131129 exit 1
132130 }
133131