Standardize verbose parameter from -vb to -ve across all scripts
- Update all Bash scripts (sf-check, sf-org-info, sf-data-export, sf-data-import, sf-logs-tail) to use -ve instead of -vb - Update all PowerShell scripts (sf-org-info.ps1, sf-apex-run.ps1, sf-check.ps1, sf-data-export.ps1, sf-data-import.ps1) to use -ve instead of -vb - Fix PowerShell parameter conflicts with built-in -Verbose parameter - Update README.md, TESTING.md, and OPTION_CONSISTENCY.md documentation to reflect -ve parameter - Update test scripts (test-wrapper-suite.sh, test-wrapper-suite.ps1, test-all-wrappers.sh) to use -ve - Maintain cross-platform consistency with two-character option scheme - Fix Unicode display issues in PowerShell output with UTF-8 encoding
This commit is contained in:
@@ -9,26 +9,26 @@
|
||||
anonymous Apex code from files or inline strings with better formatting
|
||||
and error handling.
|
||||
|
||||
.PARAMETER File
|
||||
.PARAMETER fl
|
||||
Path to Apex file to execute
|
||||
|
||||
.PARAMETER Code
|
||||
Inline Apex code to execute (alternative to -File)
|
||||
.PARAMETER code
|
||||
Inline Apex code to execute (alternative to -fl)
|
||||
|
||||
.PARAMETER o
|
||||
.PARAMETER to
|
||||
Target org username or alias (uses default if not specified)
|
||||
|
||||
.PARAMETER Verbose
|
||||
.PARAMETER ve
|
||||
Enable verbose output showing execution details
|
||||
|
||||
.PARAMETER Help
|
||||
.PARAMETER hp
|
||||
Show this help message
|
||||
|
||||
.EXAMPLE
|
||||
.\sf-apex-run.ps1 -File "scripts/setup.apex"
|
||||
.\sf-apex-run.ps1 -Code "System.debug('Hello World');"
|
||||
.\sf-apex-run.ps1 -File "test.apex" -o "sandbox"
|
||||
.\sf-apex-run.ps1 -Code "Database.insert(new Account(Name='Test'));" -Verbose
|
||||
.\sf-apex-run.ps1 -fl "scripts/setup.apex"
|
||||
.\sf-apex-run.ps1 -code "System.debug('Hello World');"
|
||||
.\sf-apex-run.ps1 -fl "test.apex" -to "sandbox"
|
||||
.\sf-apex-run.ps1 -code "Database.insert(new Account(Name='Test'));" -ve
|
||||
|
||||
.NOTES
|
||||
This script automatically checks for Salesforce CLI installation and runs
|
||||
@@ -37,18 +37,18 @@
|
||||
|
||||
param(
|
||||
[Parameter(ParameterSetName="File")]
|
||||
[string]$File,
|
||||
[string]$fl,
|
||||
|
||||
[Parameter(ParameterSetName="Code")]
|
||||
[string]$Code,
|
||||
[string]$code,
|
||||
|
||||
[string]$o,
|
||||
[switch]$Verbose,
|
||||
[switch]$Help
|
||||
[string]$to,
|
||||
[switch]$ve,
|
||||
[switch]$hp
|
||||
)
|
||||
|
||||
# Show help if requested
|
||||
if ($Help) {
|
||||
if ($hp) {
|
||||
Get-Help $MyInvocation.MyCommand.Path -Detailed
|
||||
exit 0
|
||||
}
|
||||
@@ -110,46 +110,46 @@ if (-not (Test-SalesforceCLI)) {
|
||||
}
|
||||
|
||||
# Validate that either file or code is provided
|
||||
if (-not $File -and -not $Code) {
|
||||
Write-Host "Error: Must specify either -File or -Code parameter" -ForegroundColor Red
|
||||
if (-not $fl -and -not $code) {
|
||||
Write-Host "Error: Must specify either -fl or -code parameter" -ForegroundColor Red
|
||||
Write-Host ""
|
||||
Write-Host "Usage examples:" -ForegroundColor Yellow
|
||||
Write-Host " .\sf-apex-run.ps1 -File `"scripts/setup.apex`"" -ForegroundColor Gray
|
||||
Write-Host " .\sf-apex-run.ps1 -Code `"System.debug('Hello World');`"" -ForegroundColor Gray
|
||||
Write-Host " .\sf-apex-run.ps1 -fl `"scripts/setup.apex`"" -ForegroundColor Gray
|
||||
Write-Host " .\sf-apex-run.ps1 -code `"System.debug('Hello World');`"" -ForegroundColor Gray
|
||||
Write-Host ""
|
||||
Write-Host "Use -Help for detailed usage information." -ForegroundColor Yellow
|
||||
Write-Host "Use -hp for detailed usage information." -ForegroundColor Yellow
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Validate that both file and code aren't provided
|
||||
if ($File -and $Code) {
|
||||
Write-Host "Error: Cannot specify both -File and -Code parameters" -ForegroundColor Red
|
||||
if ($fl -and $code) {
|
||||
Write-Host "Error: Cannot specify both -fl and -code parameters" -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
|
||||
# If file is specified, validate it exists and read content
|
||||
if ($File) {
|
||||
if (-not (Test-Path $File)) {
|
||||
Write-Host "Error: Apex file not found: $File" -ForegroundColor Red
|
||||
if ($fl) {
|
||||
if (-not (Test-Path $fl)) {
|
||||
Write-Host "Error: Apex file not found: $fl" -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
|
||||
try {
|
||||
$apexContent = Get-Content -Path $File -Raw
|
||||
Write-Host "Using Apex file: $File" -ForegroundColor Green
|
||||
$apexContent = Get-Content -Path $fl -Raw
|
||||
Write-Host "Using Apex file: $fl" -ForegroundColor Green
|
||||
|
||||
if ($Verbose) {
|
||||
Show-CodePreview $apexContent "from file: $File"
|
||||
if ($ve) {
|
||||
Show-CodePreview $apexContent "from file: $fl"
|
||||
}
|
||||
} catch {
|
||||
Write-Host "Error reading Apex file: $($_.Exception.Message)" -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
} else {
|
||||
$apexContent = $Code
|
||||
$apexContent = $code
|
||||
Write-Host "Using inline Apex code" -ForegroundColor Green
|
||||
|
||||
if ($Verbose) {
|
||||
if ($ve) {
|
||||
Show-CodePreview $apexContent "inline"
|
||||
}
|
||||
}
|
||||
@@ -158,16 +158,14 @@ if ($File) {
|
||||
$sfArgs = @("apex", "run")
|
||||
|
||||
# Add target org if specified
|
||||
if ($o) {
|
||||
if ($to) {
|
||||
$sfArgs += "--target-org"
|
||||
$sfArgs += $o
|
||||
Write-Host "Target org: $o" -ForegroundColor Cyan
|
||||
$sfArgs += $to
|
||||
Write-Host "Target org: $to" -ForegroundColor Cyan
|
||||
}
|
||||
|
||||
# Add verbose flag if requested
|
||||
if ($Verbose) {
|
||||
$sfArgs += "--verbose"
|
||||
}
|
||||
# Note: sf apex run doesn't support --verbose flag
|
||||
# Verbose mode only affects our script's output (code preview)
|
||||
|
||||
# Display execution info
|
||||
Write-Host ""
|
||||
@@ -176,7 +174,7 @@ Write-Host "============================" -ForegroundColor Blue
|
||||
|
||||
# Create a temporary file for the Apex content if needed
|
||||
$tempFile = $null
|
||||
if ($Code) {
|
||||
if ($code) {
|
||||
$tempFile = [System.IO.Path]::GetTempFileName() + ".apex"
|
||||
try {
|
||||
Set-Content -Path $tempFile -Value $apexContent -Encoding UTF8
|
||||
@@ -188,7 +186,7 @@ if ($Code) {
|
||||
}
|
||||
} else {
|
||||
$sfArgs += "--file"
|
||||
$sfArgs += $File
|
||||
$sfArgs += $fl
|
||||
}
|
||||
|
||||
# Display the command being run (without showing temp file path)
|
||||
@@ -212,7 +210,7 @@ try {
|
||||
Write-Host ""
|
||||
Write-Host "✅ Anonymous Apex executed successfully!" -ForegroundColor Green
|
||||
|
||||
if ($Verbose) {
|
||||
if ($ve) {
|
||||
Write-Host "💡 Check the output above for any System.debug() statements" -ForegroundColor Yellow
|
||||
}
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user