Files
sf-cli-wrapper/sf-web-open
reynold 43fc686e26 Remove all long options (--) for complete consistency
 Major Consistency Update:
- Removed ALL long options (--target-org, --help, etc.) from scripts
- Now using ONLY two-character options (-to, -hp, etc.)
- Complete consistency across all wrapper scripts

Updated Scripts:
 sf-deploy: Removed --target-org, --sources, --directory, --tests, --help
 sf-dry-run: Removed all --long options, matching sf-deploy
 sf-web-open: Removed --target-org, --path, --url-only, --help
 sf-data-export: Removed all --long options throughout
 sf-logs-tail: Removed all --long options and updated help text

Updated Test Scripts:
 test-wrapper-suite.sh: Removed --help tests and --long option tests
 quick-test.sh: Updated to use -ls instead of --list
 All tests now use only two-character options

🎯 Result: Pure two-character option interface
- Clean, consistent UX: -to, -sr, -dr, -ts, -hp, -qy, -fl, etc.
- No mixing of single-char, two-char, and long options
- Memorable, self-documenting option names throughout
2025-08-28 18:51:13 +08:00

97 lines
2.3 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
show_help() {
cat <<'EOF'
sf-web-open — wrapper for `sf org open`
USAGE:
sf-web-open [-to <ORG_ALIAS_OR_USERNAME>] [-pt <RELATIVE_PATH>] [-ur]
OPTIONS:
-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 this help
EXAMPLES:
1) Open a specific org (default home):
sf-web-open -to DEMO-ORG
2) Open Setup Home of a target org:
sf-web-open -to NUSHUB-DR2 -pt "/lightning/setup/SetupOneHome/home"
3) Get just the URL for scripting:
sf-web-open -to NUSHUB-DR2 -ur
4) Open the current default org (no -to provided):
sf-web-open
EOF
}
ORG=""
PATH_ARG=""
URL_ONLY=0
# If no args → show help + examples and exit without error
if [[ $# -eq 0 ]]; then
show_help
exit 0
fi
# Parse command line arguments using manual parsing for two-character options
while [[ $# -gt 0 ]]; do
case $1 in
-to)
ORG="$2"
shift 2
;;
-pt)
PATH_ARG="$2"
shift 2
;;
-ur)
URL_ONLY=1
shift
;;
-hp)
show_help
exit 0
;;
*)
echo "Unknown option: $1" >&2
echo
show_help
exit 1
;;
esac
done
# Silent environment check - verify SF CLI is available
if ! command -v sf >/dev/null 2>&1; then
echo "❌ Salesforce CLI (sf) not found!"
echo
echo "Running environment check to help you get started..."
echo
# Try to find and run sf-check in the same directory as this script
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
if [[ -x "$SCRIPT_DIR/sf-check" ]]; then
"$SCRIPT_DIR/sf-check"
elif command -v sf-check >/dev/null 2>&1; then
sf-check
else
echo "sf-check not found. Please install the Salesforce CLI from:"
echo "https://developer.salesforce.com/tools/sfdxcli"
fi
exit 1
fi
CMD=(sf org open)
[[ -n "$ORG" ]] && CMD+=(--target-org "$ORG")
[[ -n "$PATH_ARG" ]] && CMD+=(--path "$PATH_ARG")
[[ $URL_ONLY -eq 1 ]] && CMD+=(--url-only)
echo ">>> Running: ${CMD[*]}"
exec "${CMD[@]}"