Fix sf-org-info two-character options: standardize to -lm/-ls, update docs and tests

This commit is contained in:
reynold
2025-08-28 21:50:44 +08:00
parent 57eb6182c8
commit 7aa7a7a688
5 changed files with 61 additions and 21 deletions

View File

@@ -51,6 +51,8 @@ All scripts use an innovative **two-character option scheme** based on syllables
- `-op, --operation` - **Op**eration
- `-wt, --wait` - **W**ai**T**
- `-lv, --level` - **L**e**V**el
- `-lm` - **L**i**M**its (show org limits)
- `-ls` - **L**i**S**t (list orgs)
### Benefits
- **More Memorable**: `-to` for target-org is intuitive vs cryptic `-o`
@@ -156,10 +158,10 @@ Display org information, limits, and list authenticated orgs.
**Usage:**
```bash
sf-org-info -to ORG [--limits] [--list] [-ve]
sf-org-info -to ORG [-lm] [-ls] [-ve]
```
```powershell
sf-org-info.ps1 -to "myorg" -Limits -ve
sf-org-info.ps1 -to "myorg" -lm -ve
```
**Examples:**
@@ -168,7 +170,10 @@ sf-org-info.ps1 -to "myorg" -Limits -ve
sf-org-info -to MyOrg
# Show limits and verbose info
sf-org-info -to MyOrg --limits -ve
sf-org-info -to MyOrg -lm -ve
# List all authenticated orgs
sf-org-info -ls
```
### sf-retrieve / sf-retrieve.ps1

View File

@@ -6,10 +6,11 @@ show_help() {
sf-org-info — wrapper for quick org information display
USAGE:
sf-org-info [-to <ORG_ALIAS>] [-ve] [-ls] [-hp]
sf-org-info [-to <ORG_ALIAS>] [-lm] [-ve] [-ls] [-hp]
OPTIONS:
-to Target org alias or username (if not provided, uses default org)
-lm Show detailed org limits information
-ve Verbose output (show detailed information)
-ls List all authenticated orgs
-hp Show this help
@@ -21,10 +22,13 @@ EXAMPLES:
2) Show specific org info:
sf-org-info -to DEMO-ORG
3) Show detailed org information:
3) Show org limits:
sf-org-info -to DEMO-ORG -lm
4) Show detailed org information:
sf-org-info -to DEMO-ORG -ve
4) List all authenticated orgs:
5) List all authenticated orgs:
sf-org-info -ls
DISPLAYED INFORMATION:
@@ -47,6 +51,13 @@ EOF
ORG=""
VERBOSE=false
LIST_ORGS=false
SHOW_LIMITS=false
# Show help if no arguments provided (consistent with PowerShell version)
if [[ $# -eq 0 ]]; then
show_help
exit 0
fi
# Parse arguments manually for two-character options
while [[ $# -gt 0 ]]; do
@@ -61,11 +72,15 @@ while [[ $# -gt 0 ]]; do
exit 1
fi
;;
-lm)
SHOW_LIMITS=true
shift
;;
-ve|--verbose)
VERBOSE=true
shift
;;
-ls|--list)
-ls)
LIST_ORGS=true
shift
;;
@@ -184,6 +199,25 @@ if ! show_org_info "$ORG"; then
exit 1
fi
# Show limits if requested
if [[ "$SHOW_LIMITS" == "true" ]]; then
echo
echo "📈 Organization Limits:"
echo "======================="
cmd_args=()
if [[ -n "$ORG" ]]; then
cmd_args+=(--target-org "$ORG")
fi
if sf org list limits ${cmd_args[@]:+"${cmd_args[@]}"} 2>/dev/null; then
echo
else
echo "❌ Unable to retrieve org limits"
echo "Make sure you're authenticated and the org exists."
fi
fi
echo
echo "✅ Org information displayed successfully!"
@@ -192,4 +226,5 @@ echo
echo "💡 Helpful commands:"
echo " - Open this org: sf org open${ORG:+ --target-org \"$ORG\"}"
echo " - List all orgs: sf-org-info -ls"
echo " - Show limits: sf-org-info${ORG:+ -to \"$ORG\"} -lm"
echo " - Detailed info: sf-org-info${ORG:+ -to \"$ORG\"} -ve"

View File

@@ -12,10 +12,10 @@
.PARAMETER to
Target org username or alias (uses default if not specified)
.PARAMETER limits
.PARAMETER lm
Show detailed org limits information
.PARAMETER list
.PARAMETER ls
List all authenticated orgs
.PARAMETER ve
@@ -26,9 +26,9 @@
.EXAMPLE
.\sf-org-info.ps1
.\sf-org-info.ps1 -to "myorg" -limits -ve
.\sf-org-info.ps1 -limits
.\sf-org-info.ps1 -list
.\sf-org-info.ps1 -to "myorg" -lm -ve
.\sf-org-info.ps1 -lm
.\sf-org-info.ps1 -ls
.NOTES
This script automatically checks for Salesforce CLI installation and runs
@@ -37,14 +37,14 @@
param(
[string]$to,
[switch]$limits,
[switch]$list,
[switch]$lm,
[switch]$ls,
[switch]$ve,
[switch]$hp
)
# Show help if requested or if no parameters provided
if ($hp -or (-not $to -and -not $limits -and -not $list -and -not $ve)) {
if ($hp -or (-not $to -and -not $lm -and -not $ls -and -not $ve)) {
Get-Help $MyInvocation.MyCommand.Path -Detailed
exit 0
}
@@ -123,7 +123,7 @@ if (-not (Test-SalesforceCLI)) {
}
# If list is specified, show all authenticated orgs and exit
if ($list) {
if ($ls) {
Write-SectionHeader "Authenticated Orgs"
$success = Invoke-SafeSfCommand @("org", "list")
@@ -158,7 +158,7 @@ if (-not $success) {
}
# If limits are requested, show org limits
if ($limits) {
if ($lm) {
Write-SectionHeader "Organization Limits"
# Build limits command
@@ -204,7 +204,7 @@ if ($ve) {
Write-Host ""
Write-Host "✅ Organization information retrieved successfully!" -ForegroundColor Green
if (-not $limits -and -not $ve) {
if (-not $lm -and -not $ve) {
Write-Host ""
Write-Host "💡 Tip: Use -limits to see org limits, -ve for more details, or -list to see all authenticated orgs" -ForegroundColor Yellow
Write-Host "💡 Tip: Use -lm to see org limits, -ve for more details, or -ls to see all authenticated orgs" -ForegroundColor Yellow
}

View File

@@ -94,7 +94,7 @@ echo ""
echo -e "${BLUE}=== Testing sf-org-info ===${NC}"
run_test "sf-org-info target org" "./sf-org-info -to $TEST_ORG"
run_test "sf-org-info list orgs" "./sf-org-info --list"
run_test "sf-org-info list orgs" "./sf-org-info -ls"
echo ""
echo -e "${BLUE}=== Testing sf-web-open ===${NC}"

View File

@@ -121,7 +121,7 @@ run_test "sf-check basic" "./sf-check" 0 "Basic environment check"
run_test "sf-check verbose" "./sf-check -ve" 0 "Verbose environment check"
# Org operations
run_test "sf-org-info list" "./sf-org-info --list" 0 "List authenticated orgs"
run_test "sf-org-info list" "./sf-org-info -ls" 0 "List authenticated orgs"
# Create test files for advanced testing
echo "FirstName,LastName,Email" > "$TEST_DIR/test-contacts.csv"