Enforce strict two-character option scheme across all wrapper scripts

- Removed long options from input parsing in all bash scripts
- Updated all help texts to show only two-character options
- Fixed error messages to reference short options only
- All scripts now reject long options like --help, --verbose, --target-org
- Maintained internal use of long sf CLI commands (e.g., --target-org passed to sf)
- Updated README.md documentation to reflect two-character scheme only
- Scripts affected: sf-retrieve, sf-test-run, sf-data-import, sf-data-export
- PowerShell scripts already used correct two-character parameter scheme
- All wrapper scripts now have consistent user interface

This ensures strict consistency in the two-character option scheme
while maintaining backward compatibility for the sf CLI commands themselves.
This commit is contained in:
reynold
2025-08-28 22:07:34 +08:00
parent 7aa7a7a688
commit 1ae8df8561
9 changed files with 89 additions and 89 deletions

View File

@@ -269,7 +269,7 @@ Real-time debug logs tail with filtering, levels, and Apex-only mode.
Usage:
```bash
sf-logs-tail [-to ORG] [--user-id USER] [--level DEBUG] [--duration 60] [--filter PATTERN] [--apex-only]
sf-logs-tail [-to ORG] [-ui USER] [-lv DEBUG] [-dr 60] [-ft PATTERN] [-ax]
```
```powershell
sf-logs-tail.ps1 -TargetOrg sandbox -Level DEBUG -Duration 60 -ApexOnly -Filter "MyClass"
@@ -285,11 +285,11 @@ sf-deploy -to <ORG_ALIAS_OR_USERNAME> (-sr "<src1>,<src2>[,...]" | -dr <DIRECTOR
```
**Options:**
- `-to, --target-org` - 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 help
- `-to` - Org alias or username for --target-org
- `-sr` - Comma-separated list of --source-dir paths
- `-dr` - Single directory path to deploy (alternative to -sr)
- `-ts` - Comma-separated list of --tests (enables --test-level RunSpecifiedTests)
- `-hp` - Show help
**Examples:**
```bash
@@ -316,11 +316,11 @@ sf-dry-run -to <ORG_ALIAS_OR_USERNAME> (-sr "<src1>,<src2>[,...]" | -dr <DIRECTO
```
**Options:**
- `-to, --target-org` - 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 help
- `-to` - Org alias or username for --target-org
- `-sr` - Comma-separated list of --source-dir paths
- `-dr` - Single directory path to validate (alternative to -sr)
- `-ts` - Comma-separated list of --tests (enables --test-level RunSpecifiedTests)
- `-hp` - Show help
**Examples:**
```bash
@@ -347,10 +347,10 @@ sf-web-open [-to <ORG_ALIAS_OR_USERNAME>] [-pt <RELATIVE_PATH>] [-ur]
```
**Options:**
- `-to, --target-org` - 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` - URL-only: print the URL instead of opening a browser (passes --url-only)
- `-hp, --help` - Show help
- `-to` - Org alias or username to pass as --target-org
- `-pt` - 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` - Show help
**Examples:**
```bash
@@ -377,8 +377,8 @@ sf-check [-ve] [-hp]
```
**Options:**
- `-ve, --verbose` - Verbose output (show detailed information)
- `-hp, --help` - Show help
- `-ve` - Verbose output (show detailed information)
- `-hp` - Show help
**Examples:**
```bash

View File

@@ -62,7 +62,7 @@ fi
# Parse arguments manually for two-character options
while [[ $# -gt 0 ]]; do
case $1 in
-to|--target-org)
-to)
if [[ -n "${2:-}" && ! "$2" =~ ^- ]]; then
ORG="$2"
shift 2
@@ -72,7 +72,7 @@ while [[ $# -gt 0 ]]; do
exit 1
fi
;;
-fl|--file)
-fl)
if [[ -n "${2:-}" && ! "$2" =~ ^- ]]; then
APEX_FILE="$2"
shift 2
@@ -82,7 +82,7 @@ while [[ $# -gt 0 ]]; do
exit 1
fi
;;
-cd|--code)
-cd)
if [[ -n "${2:-}" ]]; then
APEX_CODE="$2"
shift 2
@@ -92,7 +92,7 @@ while [[ $# -gt 0 ]]; do
exit 1
fi
;;
-hp|--help)
-hp)
show_help
exit 0
;;

View File

@@ -210,11 +210,11 @@ VERBOSE=false
# Parse arguments manually for two-character options
while [[ $# -gt 0 ]]; do
case $1 in
-ve|--verbose)
-ve)
VERBOSE=true
shift
;;
-hp|--help)
-hp)
show_help
exit 0
;;

View File

@@ -185,14 +185,14 @@ query_methods=0
[[ -n "$SOBJECT" ]] && ((query_methods++))
if [[ $query_methods -eq 0 ]]; then
echo -e "${RED}Error: Must specify one of: --query, --file, or --sobject${NC}"
echo -e "${RED}Error: Must specify one of: -qy, -fl, or -so${NC}"
echo ""
echo -e "${YELLOW}Usage examples:${NC}"
echo -e "${GRAY} sf-data-export -qy \"SELECT Id, Name FROM Account\"${NC}"
echo -e "${GRAY} sf-data-export -fl queries/accounts.soql${NC}"
echo -e "${GRAY} sf-data-export -so Account${NC}"
echo ""
echo -e "${YELLOW}Use --help for detailed usage information.${NC}"
echo -e "${YELLOW}Use -hp for detailed usage information.${NC}"
exit 1
fi

View File

@@ -20,17 +20,17 @@ show_usage() {
echo " sf-data-import [OPTIONS]"
echo ""
echo "OPTIONS:"
echo " -fl, --file FILE CSV or JSON file to import"
echo " -so, --sobject SOBJECT Target sObject type"
echo " -to, --target-org ORG Target org username or alias"
echo " -op, --operation OP Operation: insert, update, upsert (default: insert)"
echo " -ei, --external-id FIELD External ID field for upsert/update operations"
echo " -bk, --bulk Use bulk API for large datasets"
echo " -wt, --wait MINUTES Wait time in minutes (default: 10)"
echo " -bs, --batch-size SIZE Batch size for bulk operations (default: 10000)"
echo " -ie, --ignore-errors Continue on errors (don't fail entire job)"
echo " -ve, --verbose Enable verbose output"
echo " -hp, --help Show this help message"
echo " -fl CSV or JSON file to import"
echo " -so Target sObject type"
echo " -to Target org username or alias"
echo " -op Operation: insert, update, upsert (default: insert)"
echo " -ei External ID field for upsert/update operations"
echo " -bk Use bulk API for large datasets"
echo " -wt Wait time in minutes (default: 10)"
echo " -bs Batch size for bulk operations (default: 10000)"
echo " -ie Continue on errors (don't fail entire job)"
echo " -ve Enable verbose output"
echo " -hp Show this help message"
echo ""
echo "EXAMPLES:"
echo " sf-data-import -fl accounts.csv -so Account"
@@ -171,47 +171,47 @@ VERBOSE=false
# Parse command line arguments
while [[ $# -gt 0 ]]; do
case $1 in
-fl|--file)
-fl)
FILE="$2"
shift 2
;;
-so|--sobject)
-so)
SOBJECT="$2"
shift 2
;;
-to|--target-org)
-to)
TARGET_ORG="$2"
shift 2
;;
-op|--operation)
-op)
OPERATION="$2"
shift 2
;;
-ei|--external-id)
-ei)
EXTERNAL_ID="$2"
shift 2
;;
-bk|--bulk)
-bk)
USE_BULK=true
shift
;;
-wt|--wait)
-wt)
WAIT_TIME="$2"
shift 2
;;
-bs|--batch-size)
-bs)
BATCH_SIZE="$2"
shift 2
;;
-ie|--ignore-errors)
-ie)
IGNORE_ERRORS=true
shift
;;
-ve|--verbose)
-ve)
VERBOSE=true
shift
;;
-hp|--help)
-hp)
show_usage
exit 0
;;
@@ -232,18 +232,18 @@ fi
# Validate required parameters
if [[ -z "$FILE" ]]; then
echo -e "${RED}Error: Must specify --file parameter${NC}"
echo -e "${RED}Error: Must specify -fl parameter${NC}"
echo ""
echo -e "${YELLOW}Usage examples:${NC}"
echo -e "${GRAY} sf-data-import --file data.csv --sobject Account${NC}"
echo -e "${GRAY} sf-data-import --file contacts.json --sobject Contact --operation upsert --external-id Email${NC}"
echo -e "${GRAY} sf-data-import -fl data.csv -so Account${NC}"
echo -e "${GRAY} sf-data-import -fl contacts.json -so Contact -op upsert -ei Email${NC}"
echo ""
echo -e "${YELLOW}Use --help for detailed usage information.${NC}"
echo -e "${YELLOW}Use -hp for detailed usage information.${NC}"
exit 1
fi
if [[ -z "$SOBJECT" ]]; then
echo -e "${RED}Error: Must specify --sobject parameter${NC}"
echo -e "${RED}Error: Must specify -so parameter${NC}"
exit 1
fi

View File

@@ -9,12 +9,12 @@ USAGE:
sf-org-create -al <ORG_NAME> [-dd <DAYS>] [-df <CONFIG_FILE>] [-st] [-tp <TEMPLATE>] [-hp]
OPTIONS:
-al, --alias Name/alias for the new scratch org (required)
-dd, --duration-days Duration in days (default: 7, max: 30)
-df, --def-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
-al Name/alias for the new scratch org (required)
-dd Duration in days (default: 7, max: 30)
-df Path to scratch org definition file (default: config/project-scratch-def.json)
-st Set as default org alias after creation
-tp Use predefined template (standard, testing, minimal, full)
-hp Show this help
EXAMPLES:
1) Create basic scratch org:
@@ -57,27 +57,27 @@ fi
# Parse command line arguments using manual parsing for two-character options
while [[ $# -gt 0 ]]; do
case $1 in
-al|--alias)
-al)
ORG_NAME="$2"
shift 2
;;
-dd|--duration-days)
-dd)
DURATION="$2"
shift 2
;;
-df|--def-file)
-df)
CONFIG_FILE="$2"
shift 2
;;
-st|--set-default)
-st)
SET_DEFAULT=true
shift
;;
-tp|--template)
-tp)
TEMPLATE="$2"
shift 2
;;
-hp|--help)
-hp)
show_help
exit 0
;;

View File

@@ -62,7 +62,7 @@ fi
# Parse arguments manually for two-character options
while [[ $# -gt 0 ]]; do
case $1 in
-to|--target-org)
-to)
if [[ -n "${2:-}" && ! "$2" =~ ^- ]]; then
ORG="$2"
shift 2
@@ -76,7 +76,7 @@ while [[ $# -gt 0 ]]; do
SHOW_LIMITS=true
shift
;;
-ve|--verbose)
-ve)
VERBOSE=true
shift
;;
@@ -84,7 +84,7 @@ while [[ $# -gt 0 ]]; do
LIST_ORGS=true
shift
;;
-hp|--help)
-hp)
show_help
exit 0
;;

View File

@@ -9,13 +9,13 @@ USAGE:
sf-retrieve -to <ORG_ALIAS> (-tp <TYPES> | -mn <MANIFEST> | -pk <PACKAGE>) [-nm <NAMES>] [-dr <DIR>] [-hp]
OPTIONS:
-to, --target-org Org alias or username to retrieve from (required)
-tp, --types Comma-separated metadata types (ApexClass,CustomObject,Flow,etc.)
-nm, --names Comma-separated component names (optional, works with -tp)
-mn, --manifest Path to manifest file (package.xml)
-pk, --package Package name to retrieve
-dr, --directory Target directory for retrieved metadata (default: force-app)
-hp, --help Show this help
-to Org alias or username to retrieve from (required)
-tp Comma-separated metadata types (ApexClass,CustomObject,Flow,etc.)
-nm Comma-separated component names (optional, works with -tp)
-mn Path to manifest file (package.xml)
-pk Package name to retrieve
-dr Target directory for retrieved metadata (default: force-app)
-hp Show this help
EXAMPLES:
1) Retrieve all Apex classes:
@@ -68,7 +68,7 @@ fi
# Parse arguments manually for two-character options
while [[ $# -gt 0 ]]; do
case $1 in
-to|--target-org)
-to)
if [[ -n "${2:-}" && ! "$2" =~ ^- ]]; then
ORG="$2"
shift 2
@@ -78,7 +78,7 @@ while [[ $# -gt 0 ]]; do
exit 1
fi
;;
-tp|--types)
-tp)
if [[ -n "${2:-}" && ! "$2" =~ ^- ]]; then
TYPES="$2"
shift 2
@@ -88,7 +88,7 @@ while [[ $# -gt 0 ]]; do
exit 1
fi
;;
-nm|--names)
-nm)
if [[ -n "${2:-}" && ! "$2" =~ ^- ]]; then
NAMES="$2"
shift 2
@@ -98,7 +98,7 @@ while [[ $# -gt 0 ]]; do
exit 1
fi
;;
-mn|--manifest)
-mn)
if [[ -n "${2:-}" && ! "$2" =~ ^- ]]; then
MANIFEST="$2"
shift 2
@@ -108,7 +108,7 @@ while [[ $# -gt 0 ]]; do
exit 1
fi
;;
-pk|--package)
-pk)
if [[ -n "${2:-}" && ! "$2" =~ ^- ]]; then
PACKAGE="$2"
shift 2
@@ -118,7 +118,7 @@ while [[ $# -gt 0 ]]; do
exit 1
fi
;;
-dr|--directory)
-dr)
if [[ -n "${2:-}" && ! "$2" =~ ^- ]]; then
TARGET_DIR="$2"
shift 2
@@ -128,7 +128,7 @@ while [[ $# -gt 0 ]]; do
exit 1
fi
;;
-hp|--help)
-hp)
show_help
exit 0
;;

View File

@@ -64,7 +64,7 @@ fi
# Parse arguments manually for two-character options
while [[ $# -gt 0 ]]; do
case $1 in
-to|--target-org)
-to)
if [[ -n "${2:-}" && ! "$2" =~ ^- ]]; then
ORG="$2"
shift 2
@@ -74,7 +74,7 @@ while [[ $# -gt 0 ]]; do
exit 1
fi
;;
-cn|--class-names)
-cn)
if [[ -n "${2:-}" && ! "$2" =~ ^- ]]; then
CLASSES="$2"
shift 2
@@ -84,7 +84,7 @@ while [[ $# -gt 0 ]]; do
exit 1
fi
;;
-sn|--suite-names)
-sn)
if [[ -n "${2:-}" && ! "$2" =~ ^- ]]; then
SUITES="$2"
shift 2
@@ -94,11 +94,11 @@ while [[ $# -gt 0 ]]; do
exit 1
fi
;;
-al|--all)
-al)
ALL_TESTS=true
shift
;;
-lv|--level)
-lv)
if [[ -n "${2:-}" && ! "$2" =~ ^- ]]; then
TEST_LEVEL="$2"
shift 2
@@ -108,11 +108,11 @@ while [[ $# -gt 0 ]]; do
exit 1
fi
;;
-cv|--coverage)
-cv)
COVERAGE=true
shift
;;
-wt|--wait)
-wt)
if [[ -n "${2:-}" && ! "$2" =~ ^- ]]; then
WAIT_TIME="$2"
shift 2
@@ -122,7 +122,7 @@ while [[ $# -gt 0 ]]; do
exit 1
fi
;;
-hp|--help)
-hp)
show_help
exit 0
;;