Update PowerShell scripts to use consistent two-character options (Part 1)

🔄 PowerShell Option Consistency - Phase 1 Complete:

 Updated Scripts:
  - sf-deploy.ps1: -to, -sr, -dr, -ts, -hp (matches Bash)
  - sf-dry-run.ps1: -to, -sr, -dr, -ts, -hp (matches Bash)
  - sf-web-open.ps1: -to, -pt, -ur, -hp (matches Bash)
  - sf-check.ps1: -vb, -hp (matches Bash)
  - sf-org-create.ps1: -al, -dd, -df, -st, -tp, -hp (matches Bash)

🎯 Consistency Achieved:
  - All parameter names now match their Bash counterparts exactly
  - Help text updated with descriptive option names
  - Examples updated to show new two-character options
  - All validation logic updated to use new parameter names

🚀 Cross-Platform Alignment:
  - PowerShell and Bash scripts now have identical option schemes
  - Users get consistent experience across platforms
  - No more confusion between single-char and two-char options

Remaining: 7 more PowerShell scripts to update for full consistency.
This commit is contained in:
reynold
2025-08-28 19:19:15 +08:00
parent f22a46d711
commit 579264e3d1
5 changed files with 133 additions and 133 deletions

View File

@@ -1,10 +1,10 @@
param(
[string]$n = "",
[int]$d = 7,
[string]$f = "",
[switch]$a,
[string]$t = "",
[switch]$h
[string]$al = "",
[int]$dd = 7,
[string]$df = "",
[switch]$st,
[string]$tp = "",
[switch]$hp
)
function Show-Help {
@@ -12,28 +12,28 @@ function Show-Help {
sf-org-create.ps1 wrapper for smart scratch org creation
USAGE:
sf-org-create.ps1 -n <ORG_NAME> [-d <DAYS>] [-f <CONFIG_FILE>] [-a] [-t <TEMPLATE>] [-h]
sf-org-create.ps1 -al <ORG_NAME> [-dd <DAYS>] [-df <CONFIG_FILE>] [-st] [-tp <TEMPLATE>] [-hp]
OPTIONS:
-n Name/alias for the new scratch org (required)
-d Duration in days (default: 7, max: 30)
-f Path to scratch org definition file (default: config/project-scratch-def.json)
-a Set as default org alias after creation
-t Use predefined template (standard, testing, minimal, full)
-h Show this help
-al Alias - name/alias for the new scratch org (required)
-dd Duration Days - duration in days (default: 7, max: 30)
-df Definition File - path to scratch org definition file (default: config/project-scratch-def.json)
-st Set Default - set as default org alias after creation
-tp Template - use predefined template (standard, testing, minimal, full)
-hp Help - show this help
EXAMPLES:
1) Create basic scratch org:
sf-org-create.ps1 -n "MyDevOrg"
sf-org-create.ps1 -al "MyDevOrg"
2) Create testing org for 1 day:
sf-org-create.ps1 -n "QuickTest" -d 1 -t testing
sf-org-create.ps1 -al "QuickTest" -dd 1 -tp testing
3) Create with custom config and set as default:
sf-org-create.ps1 -n "MainDev" -d 14 -f "config/custom-scratch-def.json" -a
sf-org-create.ps1 -al "MainDev" -dd 14 -df "config/custom-scratch-def.json" -st
4) Create full-featured org:
sf-org-create.ps1 -n "FullEnv" -t full -d 30
sf-org-create.ps1 -al "FullEnv" -tp full -dd 30
TEMPLATES:
- standard: Basic scratch org with common features
@@ -49,21 +49,21 @@ Notes:
}
# Show help if requested or no parameters
if ($h -or ($n -eq "" -and $f -eq "" -and $t -eq "")) {
if ($hp -or ($al -eq "" -and $df -eq "" -and $tp -eq "")) {
Show-Help
exit 0
}
# Validate required parameters
if ($n -eq "") {
Write-Error "Error: Org name (-n) is required."
if ($al -eq "") {
Write-Error "Error: Org alias (-al) is required."
Write-Host ""
Show-Help
exit 1
}
# Validate duration
if ($d -lt 1 -or $d -gt 30) {
if ($dd -lt 1 -or $dd -gt 30) {
Write-Error "Error: Duration must be between 1 and 30 days."
exit 1
}
@@ -170,17 +170,17 @@ function New-TemplateConfig {
$finalConfig = ""
$tempConfigCreated = $false
if ($t -ne "") {
Write-Host "📝 Creating scratch org definition from template: $t"
$finalConfig = New-TemplateConfig -Template $t
if ($tp -ne "") {
Write-Host "📝 Creating scratch org definition from template: $tp"
$finalConfig = New-TemplateConfig -Template $tp
$tempConfigCreated = $true
}
elseif ($f -ne "") {
if (-not (Test-Path $f)) {
Write-Error "Error: Config file '$f' not found."
elseif ($df -ne "") {
if (-not (Test-Path $df)) {
Write-Error "Error: Config file '$df' not found."
exit 1
}
$finalConfig = $f
$finalConfig = $df
}
elseif (Test-Path "config/project-scratch-def.json") {
Write-Host "📝 Using default config: config/project-scratch-def.json"
@@ -197,16 +197,16 @@ $cmd = @("sf", "org", "create", "scratch")
$cmd += "--definition-file"
$cmd += $finalConfig
$cmd += "--duration-days"
$cmd += $d.ToString()
$cmd += $dd.ToString()
$cmd += "--alias"
$cmd += $n
$cmd += $al
# Set as default if requested
if ($a) {
if ($st) {
$cmd += "--set-default"
}
Write-Host "🚀 Creating scratch org '$n' for $d days..."
Write-Host "🚀 Creating scratch org '$al' for $dd days..."
Write-Host ">>> Running: $($cmd -join ' ')" -ForegroundColor Yellow
Write-Host ""
@@ -215,12 +215,12 @@ try {
if ($LASTEXITCODE -eq 0) {
Write-Host ""
Write-Host "✅ Scratch org '$n' created successfully!" -ForegroundColor Green
Write-Host "✅ Scratch org '$al' created successfully!" -ForegroundColor Green
# Open the org
Write-Host "🌐 Opening org in browser..."
try {
& sf org open --target-org $n
& sf org open --target-org $al
}
catch {
Write-Host "⚠️ Could not open org in browser" -ForegroundColor Yellow
@@ -230,7 +230,7 @@ try {
Write-Host ""
Write-Host "📊 Org Information:"
try {
& sf org display --target-org $n
& sf org display --target-org $al
}
catch {
Write-Host "Could not display org info"