diff --git a/sf-apex-run b/sf-apex-run index 0e92b66..f1396d0 100755 --- a/sf-apex-run +++ b/sf-apex-run @@ -6,23 +6,23 @@ show_help() { sf-apex-run — wrapper for executing anonymous Apex code USAGE: - sf-apex-run -o (-f | -c ) [-h] + sf-apex-run -to (-fl | -cd ) [-hp] OPTIONS: - -o Org alias or username to execute in (required) - -f Path to Apex file to execute - -c Apex code string to execute directly - -h Show this help + -to Target org alias or username to execute in (required) + -fl File path to Apex file to execute + -cd Code string to execute directly + -hp Show this help EXAMPLES: 1) Execute Apex from file: - sf-apex-run -o DEMO-ORG -f "scripts/debug.apex" + sf-apex-run -to DEMO-ORG -fl "scripts/debug.apex" 2) Execute inline Apex code: - sf-apex-run -o DEMO-ORG -c "System.debug('Hello World!');" + sf-apex-run -to DEMO-ORG -cd "System.debug('Hello World!');" 3) Execute complex Apex from file: - sf-apex-run -o DEMO-ORG -f "scripts/data-cleanup.apex" + sf-apex-run -to DEMO-ORG -fl "scripts/data-cleanup.apex" COMMON USE CASES: - Running debug scripts @@ -42,7 +42,7 @@ APEX FILE EXAMPLES: ``` Notes: -- Either -f (file) or -c (code) must be specified, but not both +- Either -fl (file) or -cd (code) must be specified, but not both - Apex files should contain valid Apex code - Output will show execution results and any debug logs - Be careful with DML operations - they will actually execute! @@ -59,20 +59,61 @@ if [[ $# -eq 0 ]]; then exit 0 fi -while getopts ":o:f:c:h" opt; do - case "$opt" in - o) ORG="$OPTARG" ;; - f) APEX_FILE="$OPTARG" ;; - c) APEX_CODE="$OPTARG" ;; - h) show_help; exit 0 ;; - \?) echo "Unknown option: -$OPTARG" >&2; echo; show_help; exit 1 ;; - :) echo "Option -$OPTARG requires an argument." >&2; echo; show_help; exit 1 ;; +# Parse arguments manually for two-character options +while [[ $# -gt 0 ]]; do + case $1 in + -to|--target-org) + if [[ -n "${2:-}" && ! "$2" =~ ^- ]]; then + ORG="$2" + shift 2 + else + echo "Error: -to requires a target org argument" >&2 + show_help + exit 1 + fi + ;; + -fl|--file) + if [[ -n "${2:-}" && ! "$2" =~ ^- ]]; then + APEX_FILE="$2" + shift 2 + else + echo "Error: -fl requires a file path argument" >&2 + show_help + exit 1 + fi + ;; + -cd|--code) + if [[ -n "${2:-}" ]]; then + APEX_CODE="$2" + shift 2 + else + echo "Error: -cd requires a code argument" >&2 + show_help + exit 1 + fi + ;; + -hp|--help) + show_help + exit 0 + ;; + -*) + echo "Unknown option: $1" >&2 + echo + show_help + exit 1 + ;; + *) + echo "Unexpected argument: $1" >&2 + echo + show_help + exit 1 + ;; esac done # Validate required parameters if [[ -z "$ORG" ]]; then - echo "Error: Org (-o) is required." >&2 + echo "Error: Target org (-to) is required." >&2 echo show_help exit 1 @@ -80,14 +121,14 @@ fi # Validate that either file or code is specified, but not both if [[ -z "$APEX_FILE" && -z "$APEX_CODE" ]]; then - echo "Error: Must specify either -f (file) or -c (code)." >&2 + echo "Error: Must specify either -fl (file) or -cd (code)." >&2 echo show_help exit 1 fi if [[ -n "$APEX_FILE" && -n "$APEX_CODE" ]]; then - echo "Error: Cannot specify both -f (file) and -c (code). Use one method." >&2 + echo "Error: Cannot specify both -fl (file) and -cd (code). Use one method." >&2 echo show_help exit 1 @@ -156,7 +197,7 @@ if "${CMD[@]}"; then echo echo "💡 Next steps:" echo " - Check debug logs: sf apex get log --target-org \"$ORG\"" - echo " - View recent logs: sf-logs-tail -o \"$ORG\" (if available)" + echo " - View recent logs: sf-logs-tail -to \"$ORG\" (if available)" else RESULT=$? diff --git a/sf-check b/sf-check index 6911803..9958566 100755 --- a/sf-check +++ b/sf-check @@ -13,11 +13,11 @@ show_help() { sf-check — verify Salesforce CLI environment and configuration USAGE: - sf-check [-v] [-h] + sf-check [-vb] [-hp] OPTIONS: - -v Verbose output (show detailed information) - -h Show this help + -vb Verbose output (show detailed information) + -hp Show this help DESCRIPTION: This script verifies that the Salesforce CLI is properly installed and configured. @@ -29,7 +29,7 @@ DESCRIPTION: EXAMPLES: sf-check # Basic environment check - sf-check -v # Verbose output with detailed information + sf-check -vb # Verbose output with detailed information EOF } @@ -207,11 +207,29 @@ run_diagnostics() { # Parse command line arguments VERBOSE=false -while getopts ":vh" opt; do - case "$opt" in - v) VERBOSE=true ;; - h) show_help; exit 0 ;; - \?) echo "Unknown option: -$OPTARG" >&2; echo; show_help; exit 1 ;; +# Parse arguments manually for two-character options +while [[ $# -gt 0 ]]; do + case $1 in + -vb|--verbose) + VERBOSE=true + shift + ;; + -hp|--help) + show_help + exit 0 + ;; + -*) + echo "Unknown option: $1" >&2 + echo + show_help + exit 1 + ;; + *) + echo "Unexpected argument: $1" >&2 + echo + show_help + exit 1 + ;; esac done @@ -255,7 +273,7 @@ main() { if [[ "$VERBOSE" != "true" ]]; then echo "" - echo "Run 'sf-check -v' for detailed system information." + echo "Run 'sf-check -vb' for detailed system information." fi fi } diff --git a/sf-org-info b/sf-org-info index f97a3a5..500fd93 100755 --- a/sf-org-info +++ b/sf-org-info @@ -6,26 +6,26 @@ show_help() { sf-org-info — wrapper for quick org information display USAGE: - sf-org-info [-o ] [-v] [-l] [-h] + sf-org-info [-to ] [-vb] [-ls] [-hp] OPTIONS: - -o Org alias or username (if not provided, uses default org) - -v Verbose output (show detailed information) - -l List all authenticated orgs - -h Show this help + -to Target org alias or username (if not provided, uses default org) + -vb Verbose output (show detailed information) + -ls List all authenticated orgs + -hp Show this help EXAMPLES: 1) Show default org info: sf-org-info 2) Show specific org info: - sf-org-info -o DEMO-ORG + sf-org-info -to DEMO-ORG 3) Show detailed org information: - sf-org-info -o DEMO-ORG -v + sf-org-info -to DEMO-ORG -vb 4) List all authenticated orgs: - sf-org-info -l + sf-org-info -ls DISPLAYED INFORMATION: - Org name and ID @@ -48,14 +48,43 @@ ORG="" VERBOSE=false LIST_ORGS=false -while getopts ":o:vlh" opt; do - case "$opt" in - o) ORG="$OPTARG" ;; - v) VERBOSE=true ;; - l) LIST_ORGS=true ;; - h) show_help; exit 0 ;; - \?) echo "Unknown option: -$OPTARG" >&2; echo; show_help; exit 1 ;; - :) echo "Option -$OPTARG requires an argument." >&2; echo; show_help; exit 1 ;; +# Parse arguments manually for two-character options +while [[ $# -gt 0 ]]; do + case $1 in + -to|--target-org) + if [[ -n "${2:-}" && ! "$2" =~ ^- ]]; then + ORG="$2" + shift 2 + else + echo "Error: -to requires a target org argument" >&2 + show_help + exit 1 + fi + ;; + -vb|--verbose) + VERBOSE=true + shift + ;; + -ls|--list) + LIST_ORGS=true + shift + ;; + -hp|--help) + show_help + exit 0 + ;; + -*) + echo "Unknown option: $1" >&2 + echo + show_help + exit 1 + ;; + *) + echo "Unexpected argument: $1" >&2 + echo + show_help + exit 1 + ;; esac done @@ -162,5 +191,5 @@ echo "✅ Org information displayed successfully!" echo echo "💡 Helpful commands:" echo " - Open this org: sf org open${ORG:+ --target-org \"$ORG\"}" -echo " - List all orgs: sf-org-info -l" -echo " - Detailed info: sf-org-info${ORG:+ -o \"$ORG\"} -v" +echo " - List all orgs: sf-org-info -ls" +echo " - Detailed info: sf-org-info${ORG:+ -to \"$ORG\"} -vb" diff --git a/sf-retrieve b/sf-retrieve index e122249..59b6138 100755 --- a/sf-retrieve +++ b/sf-retrieve @@ -65,17 +65,85 @@ if [[ $# -eq 0 ]]; then exit 0 fi -while getopts ":o:t:n:m:p:d:h" opt; do - case "$opt" in - o) ORG="$OPTARG" ;; - t) TYPES="$OPTARG" ;; - n) NAMES="$OPTARG" ;; - m) MANIFEST="$OPTARG" ;; - p) PACKAGE="$OPTARG" ;; - d) TARGET_DIR="$OPTARG" ;; - h) show_help; exit 0 ;; - \?) echo "Unknown option: -$OPTARG" >&2; echo; show_help; exit 1 ;; - :) echo "Option -$OPTARG requires an argument." >&2; echo; show_help; exit 1 ;; +# Parse arguments manually for two-character options +while [[ $# -gt 0 ]]; do + case $1 in + -to|--target-org) + if [[ -n "${2:-}" && ! "$2" =~ ^- ]]; then + ORG="$2" + shift 2 + else + echo "Error: -to requires a target org argument" >&2 + show_help + exit 1 + fi + ;; + -tp|--types) + if [[ -n "${2:-}" && ! "$2" =~ ^- ]]; then + TYPES="$2" + shift 2 + else + echo "Error: -tp requires a metadata types argument" >&2 + show_help + exit 1 + fi + ;; + -nm|--names) + if [[ -n "${2:-}" && ! "$2" =~ ^- ]]; then + NAMES="$2" + shift 2 + else + echo "Error: -nm requires a names argument" >&2 + show_help + exit 1 + fi + ;; + -mn|--manifest) + if [[ -n "${2:-}" && ! "$2" =~ ^- ]]; then + MANIFEST="$2" + shift 2 + else + echo "Error: -mn requires a manifest file argument" >&2 + show_help + exit 1 + fi + ;; + -pk|--package) + if [[ -n "${2:-}" && ! "$2" =~ ^- ]]; then + PACKAGE="$2" + shift 2 + else + echo "Error: -pk requires a package name argument" >&2 + show_help + exit 1 + fi + ;; + -dr|--directory) + if [[ -n "${2:-}" && ! "$2" =~ ^- ]]; then + TARGET_DIR="$2" + shift 2 + else + echo "Error: -dr requires a directory argument" >&2 + show_help + exit 1 + fi + ;; + -hp|--help) + show_help + exit 0 + ;; + -*) + echo "Unknown option: $1" >&2 + echo + show_help + exit 1 + ;; + *) + echo "Unexpected argument: $1" >&2 + echo + show_help + exit 1 + ;; esac done diff --git a/sf-test-run b/sf-test-run index 4089293..bfc2886 100755 --- a/sf-test-run +++ b/sf-test-run @@ -6,33 +6,33 @@ show_help() { sf-test-run — wrapper for focused Apex test execution USAGE: - sf-test-run -o (-c | -s | -a) [-l ] [-r] [-w ] [-h] + sf-test-run -to (-cn | -sn | -al) [-lv ] [-cv] [-wt ] [-hp] OPTIONS: - -o Org alias or username to run tests in (required) - -c Comma-separated test class names - -s Comma-separated test suite names - -a Run all tests in the org - -l Test level (RunLocalTests, RunAllTestsInOrg, RunSpecifiedTests) - -r Generate code coverage report - -w Wait time in minutes (default: 10) - -h Show this help + -to Target org alias or username to run tests in (required) + -cn Comma-separated test class names + -sn Comma-separated test suite names + -al Run all tests in the org + -lv Test level (RunLocalTests, RunAllTestsInOrg, RunSpecifiedTests) + -cv Generate code coverage report + -wt Wait time in minutes (default: 10) + -hp Show this help EXAMPLES: 1) Run specific test classes: - sf-test-run -o DEMO-ORG -c "MyTestClass,AnotherTestClass" + sf-test-run -to DEMO-ORG -cn "MyTestClass,AnotherTestClass" 2) Run test suites: - sf-test-run -o DEMO-ORG -s "UnitTests,IntegrationTests" + sf-test-run -to DEMO-ORG -sn "UnitTests,IntegrationTests" 3) Run all local tests with coverage: - sf-test-run -o DEMO-ORG -l RunLocalTests -r + sf-test-run -to DEMO-ORG -lv RunLocalTests -cv 4) Run all tests in org (be careful!): - sf-test-run -o DEMO-ORG -a -w 30 + sf-test-run -to DEMO-ORG -al -wt 30 5) Quick test with custom wait time: - sf-test-run -o DEMO-ORG -c "QuickTest" -w 5 + sf-test-run -to DEMO-ORG -cn "QuickTest" -wt 5 TEST LEVELS: - RunLocalTests: Run all tests in your org except managed package tests @@ -41,7 +41,7 @@ TEST LEVELS: Notes: - Default wait time is 10 minutes -- Use -r to generate detailed coverage reports +- Use -cv to generate detailed coverage reports - RunAllTestsInOrg can take a very long time - Test results will be displayed in formatted output EOF @@ -61,24 +61,89 @@ if [[ $# -eq 0 ]]; then exit 0 fi -while getopts ":o:c:s:al:rw:h" opt; do - case "$opt" in - o) ORG="$OPTARG" ;; - c) CLASSES="$OPTARG" ;; - s) SUITES="$OPTARG" ;; - a) ALL_TESTS=true ;; - l) TEST_LEVEL="$OPTARG" ;; - r) COVERAGE=true ;; - w) WAIT_TIME="$OPTARG" ;; - h) show_help; exit 0 ;; - \?) echo "Unknown option: -$OPTARG" >&2; echo; show_help; exit 1 ;; - :) echo "Option -$OPTARG requires an argument." >&2; echo; show_help; exit 1 ;; +# Parse arguments manually for two-character options +while [[ $# -gt 0 ]]; do + case $1 in + -to|--target-org) + if [[ -n "${2:-}" && ! "$2" =~ ^- ]]; then + ORG="$2" + shift 2 + else + echo "Error: -to requires a target org argument" >&2 + show_help + exit 1 + fi + ;; + -cn|--class-names) + if [[ -n "${2:-}" && ! "$2" =~ ^- ]]; then + CLASSES="$2" + shift 2 + else + echo "Error: -cn requires class names argument" >&2 + show_help + exit 1 + fi + ;; + -sn|--suite-names) + if [[ -n "${2:-}" && ! "$2" =~ ^- ]]; then + SUITES="$2" + shift 2 + else + echo "Error: -sn requires suite names argument" >&2 + show_help + exit 1 + fi + ;; + -al|--all) + ALL_TESTS=true + shift + ;; + -lv|--level) + if [[ -n "${2:-}" && ! "$2" =~ ^- ]]; then + TEST_LEVEL="$2" + shift 2 + else + echo "Error: -lv requires a test level argument" >&2 + show_help + exit 1 + fi + ;; + -cv|--coverage) + COVERAGE=true + shift + ;; + -wt|--wait) + if [[ -n "${2:-}" && ! "$2" =~ ^- ]]; then + WAIT_TIME="$2" + shift 2 + else + echo "Error: -wt requires a wait time argument" >&2 + show_help + exit 1 + fi + ;; + -hp|--help) + show_help + exit 0 + ;; + -*) + echo "Unknown option: $1" >&2 + echo + show_help + exit 1 + ;; + *) + echo "Unexpected argument: $1" >&2 + echo + show_help + exit 1 + ;; esac done # Validate required parameters if [[ -z "$ORG" ]]; then - echo "Error: Org (-o) is required." >&2 + echo "Error: Target org (-to) is required." >&2 echo show_help exit 1 @@ -86,7 +151,7 @@ fi # Validate that at least one test method is specified if [[ -z "$CLASSES" && -z "$SUITES" && "$ALL_TESTS" != "true" && -z "$TEST_LEVEL" ]]; then - echo "Error: Must specify -c (classes), -s (suites), -a (all tests), or -l (test level)." >&2 + echo "Error: Must specify -cn (classes), -sn (suites), -al (all tests), or -lv (test level)." >&2 echo show_help exit 1