Apply review suggestions: Add ValidateSet and improve documentation

This commit is contained in:
Masa1984a
2025-07-03 06:29:38 +09:00
parent 11cfc055af
commit 545d78c331

View File

@@ -1,31 +1,34 @@
#------------------------------------------------------------------------------ <#
# Script: run_devcontainer_claude_code.ps1 .SYNOPSIS
# Author: [Your Name or Project Name] Automates the setup and connection to a DevContainer environment using either Docker or Podman on Windows.
# Description: Automates the setup and connection to a DevContainer environment
# using either Docker or Podman on Windows. .DESCRIPTION
# This script automates the process of initializing, starting, and connecting to a DevContainer
# IMPORTANT USAGE REQUIREMENT: using either Docker or Podman as the container backend. It must be executed from the root
# This script MUST be executed from the ROOT directory of your project. directory of your project and assumes the script is located in a 'Script' subdirectory.
# It assumes the script file itself is located in a 'Script' subdirectory.
# .PARAMETER Backend
# Assumed Project Structure: Specifies the container backend to use. Valid values are 'docker' or 'podman'.
# Project/
# ├── .devcontainer/ .EXAMPLE
# └── Script/ .\Script\run_devcontainer_claude_code.ps1 -Backend docker
# └── run_devcontainer_claude_code.ps1 <-- This script's location Uses Docker as the container backend.
#
# How to Run: .EXAMPLE
# 1. Open PowerShell. .\Script\run_devcontainer_claude_code.ps1 -Backend podman
# 2. Change your current directory to the project root: Uses Podman as the container backend.
# cd c:\path\to\your\Project
# 3. Execute the script, specifying the container backend: .NOTES
# .\Script\run_devcontainer_claude_code.ps1 -Backend <docker|podman> Project Structure:
# Project/
# The -Backend parameter is mandatory and accepts 'docker' or 'podman'. ├── .devcontainer/
#------------------------------------------------------------------------------ └── Script/
└── run_devcontainer_claude_code.ps1
#>
[CmdletBinding()] [CmdletBinding()]
param( param(
[Parameter(Mandatory=$true)] [Parameter(Mandatory=$true)]
[ValidateSet('docker','podman')]
[string]$Backend [string]$Backend
) )
@@ -33,13 +36,6 @@ param(
Write-Host "--- DevContainer Startup & Connection Script ---" Write-Host "--- DevContainer Startup & Connection Script ---"
Write-Host "Using backend: $($Backend)" Write-Host "Using backend: $($Backend)"
# Validate the input backend
if ($Backend -notin @('docker', 'podman')) {
Write-Error "Invalid backend specified. Please use 'docker' or 'podman'."
Write-Host "Usage: ." + $MyInvocation.MyCommand.Definition + " -Backend <docker|podman>"
exit 1
}
# --- Backend-Specific Initialization --- # --- Backend-Specific Initialization ---
if ($Backend -eq 'podman') { if ($Backend -eq 'podman') {
Write-Host "--- Podman Backend Initialization ---" Write-Host "--- Podman Backend Initialization ---"