added addl wrappers
This commit is contained in:
107
sf-web-logout
Executable file
107
sf-web-logout
Executable file
@@ -0,0 +1,107 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
show_help() {
|
||||
cat <<'EOF'
|
||||
sf-web-logout — wrapper for `sf org logout`
|
||||
|
||||
USAGE:
|
||||
sf-web-logout [-to <ORG_ALIAS_OR_USERNAME>] [-al] [-hp] [-ve]
|
||||
|
||||
OPTIONS:
|
||||
-to Org alias or username to logout from (passes --target-org)
|
||||
-al Logout from all authenticated orgs (passes --all)
|
||||
-ve Enable verbose output
|
||||
-hp Show this help
|
||||
|
||||
EXAMPLES:
|
||||
1) Logout from specific org:
|
||||
sf-web-logout -to DEMO
|
||||
|
||||
2) Logout from all orgs:
|
||||
sf-web-logout -al
|
||||
|
||||
3) Logout with verbose output:
|
||||
sf-web-logout -to NUSHUB-PROD -ve
|
||||
EOF
|
||||
}
|
||||
|
||||
TARGET_ORG=""
|
||||
LOGOUT_ALL=0
|
||||
VERBOSE=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)
|
||||
TARGET_ORG="$2"
|
||||
shift 2
|
||||
;;
|
||||
-al)
|
||||
LOGOUT_ALL=1
|
||||
shift
|
||||
;;
|
||||
-ve)
|
||||
VERBOSE=1
|
||||
shift
|
||||
;;
|
||||
-hp)
|
||||
show_help
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
echo "Unknown option: $1" >&2
|
||||
echo
|
||||
show_help
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# Validate that both target org and all aren't specified
|
||||
if [[ -n "$TARGET_ORG" && $LOGOUT_ALL -eq 1 ]]; then
|
||||
echo "Error: Cannot specify both -to and -al options" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 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 logout)
|
||||
|
||||
[[ -n "$TARGET_ORG" ]] && CMD+=(--target-org "$TARGET_ORG")
|
||||
[[ $LOGOUT_ALL -eq 1 ]] && CMD+=(--all)
|
||||
|
||||
if [[ $VERBOSE -eq 1 ]]; then
|
||||
echo "🚪 Starting Logout Process"
|
||||
echo "========================="
|
||||
[[ -n "$TARGET_ORG" ]] && echo "Target org: $TARGET_ORG"
|
||||
[[ $LOGOUT_ALL -eq 1 ]] && echo "Logout from: All authenticated orgs"
|
||||
echo
|
||||
fi
|
||||
|
||||
echo ">>> Running: ${CMD[*]}"
|
||||
exec "${CMD[@]}"
|
||||
Reference in New Issue
Block a user