Update core wrapper scripts to use two-character option scheme

- Updated sf-deploy: -o → -to, -s → -sr, -d → -dr, -t → -ts
- Updated sf-dry-run: same options as sf-deploy for consistency
- Updated sf-web-open: -o → -to, -p → -pt, -U → -ur
- Updated sf-org-create: -n → -al, -d → -dd, -f → -df, -a → -st, -t → -tp
- All scripts now use manual argument parsing to support two-character options
- Help sections updated with both short and long option forms
- Maintains backward compatibility with long options
- Consistent with README documentation and two-character scheme
This commit is contained in:
reynold
2025-08-28 18:28:23 +08:00
parent 4bae7d48fa
commit 39b7f11646
4 changed files with 177 additions and 97 deletions

View File

@@ -6,28 +6,28 @@ show_help() {
sf-org-create — wrapper for smart scratch org creation
USAGE:
sf-org-create -n <ORG_NAME> [-d <DAYS>] [-f <CONFIG_FILE>] [-a <ALIAS>] [-t <TEMPLATE>] [-h]
sf-org-create -al <ORG_NAME> [-dd <DAYS>] [-df <CONFIG_FILE>] [-st] [-tp <TEMPLATE>] [-hp]
OPTIONS:
-n Name/alias for the new scratch org (required)
-d Duration in days (default: 7, max: 30)
-f Path to scratch org definition file (default: config/project-scratch-def.json)
-a Set as default org alias after creation
-t Use predefined template (standard, testing, minimal, full)
-h Show this help
-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
EXAMPLES:
1) Create basic scratch org:
sf-org-create -n "MyDevOrg"
sf-org-create -al "MyDevOrg"
2) Create testing org for 1 day:
sf-org-create -n "QuickTest" -d 1 -t testing
sf-org-create -al "QuickTest" -dd 1 -tp testing
3) Create with custom config and set as default:
sf-org-create -n "MainDev" -d 14 -f "config/custom-scratch-def.json" -a
sf-org-create -al "MainDev" -dd 14 -df "config/custom-scratch-def.json" -st
4) Create full-featured org:
sf-org-create -n "FullEnv" -t full -d 30
sf-org-create -al "FullEnv" -tp full -dd 30
TEMPLATES:
- standard: Basic scratch org with common features
@@ -54,22 +54,45 @@ if [[ $# -eq 0 ]]; then
exit 0
fi
while getopts ":n:d:f:at:h" opt; do
case "$opt" in
n) ORG_NAME="$OPTARG" ;;
d) DURATION="$OPTARG" ;;
f) CONFIG_FILE="$OPTARG" ;;
a) SET_DEFAULT=true ;;
t) TEMPLATE="$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 ;;
esac
# Parse command line arguments using manual parsing for two-character options
while [[ $# -gt 0 ]]; do
case $1 in
-al|--alias)
ORG_NAME="$2"
shift 2
;;
-dd|--duration-days)
DURATION="$2"
shift 2
;;
-df|--def-file)
CONFIG_FILE="$2"
shift 2
;;
-st|--set-default)
SET_DEFAULT=true
shift
;;
-tp|--template)
TEMPLATE="$2"
shift 2
;;
-hp|--help)
show_help
exit 0
;;
*)
echo "Unknown option: $1" >&2
echo
show_help
exit 1
;;
esac
done
# Validate required parameters
if [[ -z "$ORG_NAME" ]]; then
echo "Error: Org name (-n) is required." >&2
echo "Error: Org alias (-al) is required." >&2
echo
show_help
exit 1