added addl wrappers
This commit is contained in:
166
sf-org-info
Executable file
166
sf-org-info
Executable file
@@ -0,0 +1,166 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
show_help() {
|
||||
cat <<'EOF'
|
||||
sf-org-info — wrapper for quick org information display
|
||||
|
||||
USAGE:
|
||||
sf-org-info [-o <ORG_ALIAS>] [-v] [-l] [-h]
|
||||
|
||||
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
|
||||
|
||||
EXAMPLES:
|
||||
1) Show default org info:
|
||||
sf-org-info
|
||||
|
||||
2) Show specific org info:
|
||||
sf-org-info -o DEMO-ORG
|
||||
|
||||
3) Show detailed org information:
|
||||
sf-org-info -o DEMO-ORG -v
|
||||
|
||||
4) List all authenticated orgs:
|
||||
sf-org-info -l
|
||||
|
||||
DISPLAYED INFORMATION:
|
||||
- Org name and ID
|
||||
- Username and user info
|
||||
- Instance URL and login URL
|
||||
- Org type and edition
|
||||
- API version and features
|
||||
- Limits and usage (verbose mode)
|
||||
- Connected app info (verbose mode)
|
||||
|
||||
Notes:
|
||||
- If no org is specified, uses the default org
|
||||
- Verbose mode shows limits, features, and additional details
|
||||
- List mode shows all orgs you're authenticated to
|
||||
EOF
|
||||
}
|
||||
|
||||
# Default values
|
||||
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 ;;
|
||||
esac
|
||||
done
|
||||
|
||||
# Silent environment check
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
# Function to display org list
|
||||
show_org_list() {
|
||||
echo "📋 Authenticated Organizations:"
|
||||
echo "=============================="
|
||||
|
||||
if sf org list --json >/dev/null 2>&1; then
|
||||
sf org list 2>/dev/null || {
|
||||
echo "No authenticated orgs found."
|
||||
echo "Run 'sf org login web' to authenticate to an org."
|
||||
return 1
|
||||
}
|
||||
else
|
||||
echo "❌ Unable to list orgs"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to display org information
|
||||
show_org_info() {
|
||||
local target_org="$1"
|
||||
local cmd_args=()
|
||||
|
||||
if [[ -n "$target_org" ]]; then
|
||||
cmd_args+=(--target-org "$target_org")
|
||||
echo "🏢 Organization Information: $target_org"
|
||||
else
|
||||
echo "🏢 Default Organization Information:"
|
||||
fi
|
||||
echo "======================================="
|
||||
|
||||
# Get basic org info
|
||||
if sf org display "${cmd_args[@]}" --json >/dev/null 2>&1; then
|
||||
echo
|
||||
echo "📊 Basic Information:"
|
||||
sf org display "${cmd_args[@]}" 2>/dev/null || {
|
||||
echo "❌ Unable to retrieve org information"
|
||||
return 1
|
||||
}
|
||||
else
|
||||
echo "❌ Unable to retrieve org information"
|
||||
echo "Make sure you're authenticated and the org exists."
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Show verbose information if requested
|
||||
if [[ "$VERBOSE" == "true" ]]; then
|
||||
echo
|
||||
echo "📈 Org Limits:"
|
||||
echo "-------------"
|
||||
if sf org list limits "${cmd_args[@]}" >/dev/null 2>&1; then
|
||||
sf org list limits "${cmd_args[@]}" 2>/dev/null | head -20 || echo "Unable to retrieve org limits"
|
||||
else
|
||||
echo "Unable to retrieve org limits"
|
||||
fi
|
||||
|
||||
echo
|
||||
echo "⚙️ Org Shape (if available):"
|
||||
echo "-----------------------------"
|
||||
if sf org list shape "${cmd_args[@]}" >/dev/null 2>&1; then
|
||||
sf org list shape "${cmd_args[@]}" 2>/dev/null || echo "No org shapes available"
|
||||
else
|
||||
echo "No org shapes available"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# Handle list orgs option
|
||||
if [[ "$LIST_ORGS" == "true" ]]; then
|
||||
show_org_list
|
||||
exit $?
|
||||
fi
|
||||
|
||||
# Show org information
|
||||
if ! show_org_info "$ORG"; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo
|
||||
echo "✅ Org information displayed successfully!"
|
||||
|
||||
# Show helpful commands
|
||||
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"
|
||||
Reference in New Issue
Block a user