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:
18
sf-check.ps1
18
sf-check.ps1
@@ -1,6 +1,6 @@
|
||||
param(
|
||||
[switch]$v,
|
||||
[switch]$h
|
||||
[switch]$vb,
|
||||
[switch]$hp
|
||||
)
|
||||
|
||||
function Show-Help {
|
||||
@@ -8,11 +8,11 @@ function Show-Help {
|
||||
sf-check.ps1 — verify Salesforce CLI environment and configuration
|
||||
|
||||
USAGE:
|
||||
sf-check.ps1 [-v] [-h]
|
||||
sf-check.ps1 [-vb] [-hp]
|
||||
|
||||
OPTIONS:
|
||||
-v Verbose output (show detailed information)
|
||||
-h Show this help
|
||||
-vb Verbose output (show detailed information)
|
||||
-hp Help - show this help
|
||||
|
||||
DESCRIPTION:
|
||||
This script verifies that the Salesforce CLI is properly installed and configured.
|
||||
@@ -24,7 +24,7 @@ DESCRIPTION:
|
||||
|
||||
EXAMPLES:
|
||||
sf-check.ps1 # Basic environment check
|
||||
sf-check.ps1 -v # Verbose output with detailed information
|
||||
sf-check.ps1 -vb # Verbose output with detailed information
|
||||
"@
|
||||
}
|
||||
|
||||
@@ -276,13 +276,13 @@ function Test-Diagnostics {
|
||||
}
|
||||
|
||||
# Show help if requested
|
||||
if ($h) {
|
||||
if ($hp) {
|
||||
Show-Help
|
||||
exit 0
|
||||
}
|
||||
|
||||
# Set verbose flag
|
||||
$Verbose = $v
|
||||
$Verbose = $vb
|
||||
|
||||
# Main execution
|
||||
function Main {
|
||||
@@ -328,7 +328,7 @@ function Main {
|
||||
|
||||
if (-not $Verbose) {
|
||||
Write-Host ""
|
||||
Write-Host "Run 'sf-check.ps1 -v' for detailed system information."
|
||||
Write-Host "Run 'sf-check.ps1 -vb' for detailed system information."
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
param(
|
||||
[string]$o = "",
|
||||
[string]$s = "",
|
||||
[string]$d = "",
|
||||
[string]$t = "",
|
||||
[switch]$h
|
||||
[string]$to = "",
|
||||
[string]$sr = "",
|
||||
[string]$dr = "",
|
||||
[string]$ts = "",
|
||||
[switch]$hp
|
||||
)
|
||||
|
||||
function Show-Help {
|
||||
@@ -11,53 +11,53 @@ function Show-Help {
|
||||
sf-deploy.ps1 — PowerShell wrapper for ``sf project deploy start``
|
||||
|
||||
USAGE:
|
||||
sf-deploy.ps1 -o <ORG_ALIAS_OR_USERNAME> (-s "<src1>,<src2>[,...]" | -d <DIRECTORY>) [-t "<Test1>,<Test2>[,...]"]
|
||||
sf-deploy.ps1 -h
|
||||
sf-deploy.ps1 -to <ORG_ALIAS_OR_USERNAME> (-sr "<src1>,<src2>[,...]" | -dr <DIRECTORY>) [-ts "<Test1>,<Test2>[,...]"]
|
||||
sf-deploy.ps1 -hp
|
||||
|
||||
OPTIONS:
|
||||
-o Org alias or username for --target-org
|
||||
-s Comma-separated list of --source-dir paths
|
||||
-d Single directory path to deploy (alternative to -s)
|
||||
-t Comma-separated list of --tests (enables --test-level RunSpecifiedTests)
|
||||
-h Show this help
|
||||
-to Target org alias or username for --target-org
|
||||
-sr Sources - comma-separated list of --source-dir paths
|
||||
-dr Directory - single directory path to deploy (alternative to -sr)
|
||||
-ts Tests - comma-separated list of --tests (enables --test-level RunSpecifiedTests)
|
||||
-hp Help - show this help
|
||||
|
||||
EXAMPLES:
|
||||
1) Real deploy with multiple flexipages (specific files):
|
||||
sf-deploy.ps1 -o "DEMO-ORG" ``
|
||||
-s "force-app/main/default/flexipages/Sample_Page.flexipage-meta.xml,force-app/main/default/flexipages/Sample_Page_Backup_With_SalesNavigator.flexipage-meta.xml,force-app/main/default/flexipages/Sample_Role_Record_Page.flexipage-meta.xml"
|
||||
sf-deploy.ps1 -to "DEMO-ORG" ``
|
||||
-sr "force-app/main/default/flexipages/Sample_Page.flexipage-meta.xml,force-app/main/default/flexipages/Sample_Page_Backup_With_SalesNavigator.flexipage-meta.xml,force-app/main/default/flexipages/Sample_Role_Record_Page.flexipage-meta.xml"
|
||||
|
||||
2) Real deploy with entire directory:
|
||||
sf-deploy.ps1 -o "DEMO-ORG" -d "force-app/main/default/classes"
|
||||
sf-deploy.ps1 -to "DEMO-ORG" -dr "force-app/main/default/classes"
|
||||
|
||||
3) Real deploy with specified tests:
|
||||
sf-deploy.ps1 -o "DEMO-ORG" ``
|
||||
-s "force-app/main/default/flexipages/Demo_Page.flexipage-meta.xml,force-app/main/default/flexipages/Demo_Page_Backup_With_SalesNavigator.flexipage-meta.xml" ``
|
||||
-t "SelectorOpportunity_Test,SelectorOpportunity2_Test"
|
||||
sf-deploy.ps1 -to "DEMO-ORG" ``
|
||||
-sr "force-app/main/default/flexipages/Demo_Page.flexipage-meta.xml,force-app/main/default/flexipages/Demo_Page_Backup_With_SalesNavigator.flexipage-meta.xml" ``
|
||||
-ts "SelectorOpportunity_Test,SelectorOpportunity2_Test"
|
||||
|
||||
Notes:
|
||||
- Use -s for specific files (comma-separated) OR -d for entire directories (not both).
|
||||
- Use -sr for specific files (comma-separated) OR -dr for entire directories (not both).
|
||||
- Pass absolute or repo-relative paths.
|
||||
- Multiple tests are comma-separated in -t; they will be expanded to multiple --tests flags.
|
||||
- Multiple tests are comma-separated in -ts; they will be expanded to multiple --tests flags.
|
||||
"@
|
||||
}
|
||||
|
||||
# Show help if requested or no parameters provided
|
||||
if ($h -or ($o -eq "" -and $s -eq "" -and $d -eq "" -and $t -eq "")) {
|
||||
if ($hp -or ($to -eq "" -and $sr -eq "" -and $dr -eq "" -and $ts -eq "")) {
|
||||
Show-Help
|
||||
exit 0
|
||||
}
|
||||
|
||||
# Validate that either -s or -d is provided, but not both
|
||||
if ($s -ne "" -and $d -ne "") {
|
||||
Write-Error "Cannot use both -s and -d options. Use -s for specific files or -d for directories."
|
||||
# Validate that either -sr or -dr is provided, but not both
|
||||
if ($sr -ne "" -and $dr -ne "") {
|
||||
Write-Error "Cannot use both -sr and -dr options. Use -sr for specific files or -dr for directories."
|
||||
Write-Host ""
|
||||
Show-Help
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Validate required parameters
|
||||
if ($o -eq "" -or ($s -eq "" -and $d -eq "")) {
|
||||
Write-Error "Must provide -o (org) and either -s (specific files) or -d (directory path)."
|
||||
if ($to -eq "" -or ($sr -eq "" -and $dr -eq "")) {
|
||||
Write-Error "Must provide -to (org) and either -sr (specific files) or -dr (directory path)."
|
||||
Write-Host ""
|
||||
Show-Help
|
||||
exit 1
|
||||
@@ -94,8 +94,8 @@ catch {
|
||||
$cmd = @("sf", "project", "deploy", "start")
|
||||
|
||||
# Add source directories (specific files)
|
||||
if ($s -ne "") {
|
||||
$sourcesArray = $s -split ","
|
||||
if ($sr -ne "") {
|
||||
$sourcesArray = $sr -split ","
|
||||
foreach ($src in $sourcesArray) {
|
||||
$src = $src.Trim()
|
||||
if ($src -ne "") {
|
||||
@@ -106,20 +106,20 @@ if ($s -ne "") {
|
||||
}
|
||||
|
||||
# Add directory path
|
||||
if ($d -ne "") {
|
||||
if ($dr -ne "") {
|
||||
$cmd += "--source-dir"
|
||||
$cmd += $d
|
||||
$cmd += $dr
|
||||
}
|
||||
|
||||
# Add target org
|
||||
if ($o -ne "") {
|
||||
if ($to -ne "") {
|
||||
$cmd += "--target-org"
|
||||
$cmd += $o
|
||||
$cmd += $to
|
||||
}
|
||||
|
||||
# Add tests if specified
|
||||
if ($t -ne "") {
|
||||
$testsArray = $t -split ","
|
||||
if ($ts -ne "") {
|
||||
$testsArray = $ts -split ","
|
||||
$cmd += "--test-level"
|
||||
$cmd += "RunSpecifiedTests"
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
param(
|
||||
[string]$o = "",
|
||||
[string]$s = "",
|
||||
[string]$d = "",
|
||||
[string]$t = "",
|
||||
[switch]$h
|
||||
[string]$to = "",
|
||||
[string]$sr = "",
|
||||
[string]$dr = "",
|
||||
[string]$ts = "",
|
||||
[switch]$hp
|
||||
)
|
||||
|
||||
function Show-Help {
|
||||
@@ -11,53 +11,53 @@ function Show-Help {
|
||||
sf-dry-run.ps1 — PowerShell wrapper for ``sf project deploy start --dry-run``
|
||||
|
||||
USAGE:
|
||||
sf-dry-run.ps1 -o <ORG_ALIAS_OR_USERNAME> (-s "<src1>,<src2>[,...]" | -d <DIRECTORY>) [-t "<Test1>,<Test2>[,...]"]
|
||||
sf-dry-run.ps1 -h
|
||||
sf-dry-run.ps1 -to <ORG_ALIAS_OR_USERNAME> (-sr "<src1>,<src2>[,...]" | -dr <DIRECTORY>) [-ts "<Test1>,<Test2>[,...]"]
|
||||
sf-dry-run.ps1 -hp
|
||||
|
||||
OPTIONS:
|
||||
-o Org alias or username for --target-org
|
||||
-s Comma-separated list of --source-dir paths
|
||||
-d Single directory path to validate (alternative to -s)
|
||||
-t Comma-separated list of --tests (enables --test-level RunSpecifiedTests)
|
||||
-h Show this help
|
||||
-to Target org alias or username for --target-org
|
||||
-sr Sources - comma-separated list of --source-dir paths
|
||||
-dr Directory - single directory path to validate (alternative to -sr)
|
||||
-ts Tests - comma-separated list of --tests (enables --test-level RunSpecifiedTests)
|
||||
-hp Help - show this help
|
||||
|
||||
EXAMPLES:
|
||||
1) Basic dry-run with multiple flexipages (specific files):
|
||||
sf-dry-run.ps1 -o "DEMO-ORG" ``
|
||||
-s "force-app/main/default/flexipages/Sample_Page.flexipage-meta.xml,force-app/main/default/flexipages/Sample_SalesNavigator.flexipage-meta.xml,force-app/main/default/flexipages/Sample_Role_Record_Page.flexipage-meta.xml"
|
||||
sf-dry-run.ps1 -to "DEMO-ORG" ``
|
||||
-sr "force-app/main/default/flexipages/Sample_Page.flexipage-meta.xml,force-app/main/default/flexipages/Sample_SalesNavigator.flexipage-meta.xml,force-app/main/default/flexipages/Sample_Role_Record_Page.flexipage-meta.xml"
|
||||
|
||||
2) Dry-run validation for entire directory:
|
||||
sf-dry-run.ps1 -o "DEMO-ORG" -d "force-app/main/default/classes"
|
||||
sf-dry-run.ps1 -to "DEMO-ORG" -dr "force-app/main/default/classes"
|
||||
|
||||
3) Dry-run with specified tests:
|
||||
sf-dry-run.ps1 -o "DEMO-ORG" ``
|
||||
-s "force-app/main/default/flexipages/Demo_Page.flexipage-meta.xml,force-app/main/default/flexipages/Demo_Page_Backup_With_SalesNavigator.flexipage-meta.xml" ``
|
||||
-t "SelectorOpportunity_Test,SelectorOpportunity2_Test"
|
||||
sf-dry-run.ps1 -to "DEMO-ORG" ``
|
||||
-sr "force-app/main/default/flexipages/Demo_Page.flexipage-meta.xml,force-app/main/default/flexipages/Demo_Page_Backup_With_SalesNavigator.flexipage-meta.xml" ``
|
||||
-ts "SelectorOpportunity_Test,SelectorOpportunity2_Test"
|
||||
|
||||
Notes:
|
||||
- Use -s for specific files (comma-separated) OR -d for entire directories (not both).
|
||||
- Use -sr for specific files (comma-separated) OR -dr for entire directories (not both).
|
||||
- Pass absolute or repo-relative paths.
|
||||
- Multiple tests are comma-separated in -t; they will be expanded to multiple --tests flags.
|
||||
- Multiple tests are comma-separated in -ts; they will be expanded to multiple --tests flags.
|
||||
"@
|
||||
}
|
||||
|
||||
# Show help if requested or no parameters provided
|
||||
if ($h -or ($o -eq "" -and $s -eq "" -and $d -eq "" -and $t -eq "")) {
|
||||
if ($hp -or ($to -eq "" -and $sr -eq "" -and $dr -eq "" -and $ts -eq "")) {
|
||||
Show-Help
|
||||
exit 0
|
||||
}
|
||||
|
||||
# Validate that either -s or -d is provided, but not both
|
||||
if ($s -ne "" -and $d -ne "") {
|
||||
Write-Error "Cannot use both -s and -d options. Use -s for specific files or -d for directories."
|
||||
# Validate that either -sr or -dr is provided, but not both
|
||||
if ($sr -ne "" -and $dr -ne "") {
|
||||
Write-Error "Cannot use both -sr and -dr options. Use -sr for specific files or -dr for directories."
|
||||
Write-Host ""
|
||||
Show-Help
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Validate required parameters
|
||||
if ($o -eq "" -or ($s -eq "" -and $d -eq "")) {
|
||||
Write-Error "Must provide -o (org) and either -s (specific files) or -d (directory path)."
|
||||
if ($to -eq "" -or ($sr -eq "" -and $dr -eq "")) {
|
||||
Write-Error "Must provide -to (org) and either -sr (specific files) or -dr (directory path)."
|
||||
Write-Host ""
|
||||
Show-Help
|
||||
exit 1
|
||||
@@ -94,8 +94,8 @@ catch {
|
||||
$cmd = @("sf", "project", "deploy", "start", "--dry-run")
|
||||
|
||||
# Add source directories (specific files)
|
||||
if ($s -ne "") {
|
||||
$sourcesArray = $s -split ","
|
||||
if ($sr -ne "") {
|
||||
$sourcesArray = $sr -split ","
|
||||
foreach ($src in $sourcesArray) {
|
||||
$src = $src.Trim()
|
||||
if ($src -ne "") {
|
||||
@@ -106,20 +106,20 @@ if ($s -ne "") {
|
||||
}
|
||||
|
||||
# Add directory path
|
||||
if ($d -ne "") {
|
||||
if ($dr -ne "") {
|
||||
$cmd += "--source-dir"
|
||||
$cmd += $d
|
||||
$cmd += $dr
|
||||
}
|
||||
|
||||
# Add target org
|
||||
if ($o -ne "") {
|
||||
if ($to -ne "") {
|
||||
$cmd += "--target-org"
|
||||
$cmd += $o
|
||||
$cmd += $to
|
||||
}
|
||||
|
||||
# Add tests if specified
|
||||
if ($t -ne "") {
|
||||
$testsArray = $t -split ","
|
||||
if ($ts -ne "") {
|
||||
$testsArray = $ts -split ","
|
||||
$cmd += "--test-level"
|
||||
$cmd += "RunSpecifiedTests"
|
||||
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
param(
|
||||
[string]$o = "",
|
||||
[string]$p = "",
|
||||
[switch]$U,
|
||||
[switch]$h
|
||||
[string]$to = "",
|
||||
[string]$pt = "",
|
||||
[switch]$ur,
|
||||
[switch]$hp
|
||||
)
|
||||
|
||||
function Show-Help {
|
||||
@@ -10,38 +10,38 @@ function Show-Help {
|
||||
sf-web-open.ps1 — PowerShell wrapper for ``sf org open``
|
||||
|
||||
USAGE:
|
||||
sf-web-open.ps1 [-o <ORG_ALIAS_OR_USERNAME>] [-p <RELATIVE_PATH>] [-U]
|
||||
sf-web-open.ps1 -h
|
||||
sf-web-open.ps1 [-to <ORG_ALIAS_OR_USERNAME>] [-pt <RELATIVE_PATH>] [-ur]
|
||||
sf-web-open.ps1 -hp
|
||||
|
||||
OPTIONS:
|
||||
-o Org alias or username to pass as --target-org
|
||||
-p Relative path to open inside the org (e.g., "/lightning/setup/SetupOneHome/home")
|
||||
-U URL-only: print the URL instead of opening a browser (passes --url-only)
|
||||
-h Show this help
|
||||
-to Target org alias or username to pass as --target-org
|
||||
-pt Path - relative path to open inside the org (e.g., "/lightning/setup/SetupOneHome/home")
|
||||
-ur URL-only: print the URL instead of opening a browser (passes --url-only)
|
||||
-hp Help - show this help
|
||||
|
||||
EXAMPLES:
|
||||
1) Open a specific org (default home):
|
||||
sf-web-open.ps1 -o "DEMO-ORG"
|
||||
sf-web-open.ps1 -to "DEMO-ORG"
|
||||
|
||||
2) Open Setup Home of a target org:
|
||||
sf-web-open.ps1 -o "NUSHUB-DR2" -p "/lightning/setup/SetupOneHome/home"
|
||||
sf-web-open.ps1 -to "NUSHUB-DR2" -pt "/lightning/setup/SetupOneHome/home"
|
||||
|
||||
3) Get just the URL for scripting:
|
||||
sf-web-open.ps1 -o "NUSHUB-DR2" -U
|
||||
sf-web-open.ps1 -to "NUSHUB-DR2" -ur
|
||||
|
||||
4) Open the current default org (no -o provided):
|
||||
4) Open the current default org (no -to provided):
|
||||
sf-web-open.ps1
|
||||
"@
|
||||
}
|
||||
|
||||
# Show help if requested
|
||||
if ($h) {
|
||||
if ($hp) {
|
||||
Show-Help
|
||||
exit 0
|
||||
}
|
||||
|
||||
# If no parameters provided, show help and examples
|
||||
if ($o -eq "" -and $p -eq "" -and -not $U) {
|
||||
if ($to -eq "" -and $pt -eq "" -and -not $ur) {
|
||||
Show-Help
|
||||
exit 0
|
||||
}
|
||||
@@ -77,19 +77,19 @@ catch {
|
||||
$cmd = @("sf", "org", "open")
|
||||
|
||||
# Add target org if specified
|
||||
if ($o -ne "") {
|
||||
if ($to -ne "") {
|
||||
$cmd += "--target-org"
|
||||
$cmd += $o
|
||||
$cmd += $to
|
||||
}
|
||||
|
||||
# Add path if specified
|
||||
if ($p -ne "") {
|
||||
if ($pt -ne "") {
|
||||
$cmd += "--path"
|
||||
$cmd += $p
|
||||
$cmd += $pt
|
||||
}
|
||||
|
||||
# Add URL-only flag if specified
|
||||
if ($U) {
|
||||
if ($ur) {
|
||||
$cmd += "--url-only"
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user