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:
74
sf-deploy
74
sf-deploy
@@ -6,32 +6,32 @@ show_help() {
|
||||
sf-deploy — wrapper for `sf project deploy start`
|
||||
|
||||
USAGE:
|
||||
sf-deploy -o <ORG_ALIAS_OR_USERNAME> (-s "<src1>,<src2>[,...]" | -d <DIRECTORY>) [-t "<Test1>,<Test2>[,...]"]
|
||||
sf-deploy -to <ORG_ALIAS_OR_USERNAME> (-sr "<src1>,<src2>[,...]" | -dr <DIRECTORY>) [-ts "<Test1>,<Test2>[,...]"]
|
||||
|
||||
OPTIONS:
|
||||
-o Org alias or username for --target-org
|
||||
-s Comma-separated list of --source-dir paths
|
||||
-d Single directory path to deploy (alternative to -s)
|
||||
-t Comma-separated list of --tests (enables --test-level RunSpecifiedTests)
|
||||
-h Show this help
|
||||
-to, --target-org Org alias or username for --target-org
|
||||
-sr, --sources Comma-separated list of --source-dir paths
|
||||
-dr, --directory Single directory path to deploy (alternative to -sr)
|
||||
-ts, --tests Comma-separated list of --tests (enables --test-level RunSpecifiedTests)
|
||||
-hp, --help Show this help
|
||||
|
||||
EXAMPLES:
|
||||
1) Real deploy with multiple flexipages (specific files):
|
||||
sf-deploy -o DEMO-ORG \
|
||||
-s "force-app/main/default/flexipages/Sample_Page.flexipage-meta.xml,force-app/main/default/flexipages/Sample_Page_Backup_With_SalesNavigator.flexipage-meta.xml,force-app/main/default/flexipages/Sample_Role_Record_Page.flexipage-meta.xml"
|
||||
sf-deploy -to DEMO-ORG \
|
||||
-sr "force-app/main/default/flexipages/Sample_Page.flexipage-meta.xml,force-app/main/default/flexipages/Sample_Page_Backup_With_SalesNavigator.flexipage-meta.xml,force-app/main/default/flexipages/Sample_Role_Record_Page.flexipage-meta.xml"
|
||||
|
||||
2) Real deploy with entire directory:
|
||||
sf-deploy -o DEMO-ORG -d "force-app/main/default/classes"
|
||||
sf-deploy -to DEMO-ORG -dr "force-app/main/default/classes"
|
||||
|
||||
3) Real deploy with specified tests:
|
||||
sf-deploy -o DEMO-ORG \
|
||||
-s "force-app/main/default/flexipages/Demo_Page.flexipage-meta.xml,force-app/main/default/flexipages/Demo_Page_Backup_With_SalesNavigator.flexipage-meta.xml" \
|
||||
-t "SelectorOpportunity_Test,SelectorOpportunity2_Test"
|
||||
sf-deploy -to DEMO-ORG \
|
||||
-sr "force-app/main/default/flexipages/Demo_Page.flexipage-meta.xml,force-app/main/default/flexipages/Demo_Page_Backup_With_SalesNavigator.flexipage-meta.xml" \
|
||||
-ts "SelectorOpportunity_Test,SelectorOpportunity2_Test"
|
||||
|
||||
Notes:
|
||||
- Use -s for specific files (comma-separated) OR -d for entire directories (not both).
|
||||
- Use -sr for specific files (comma-separated) OR -dr for entire directories (not both).
|
||||
- Pass absolute or repo-relative paths.
|
||||
- Multiple tests are comma-separated in -t; they will be expanded to multiple --tests flags.
|
||||
- Multiple tests are comma-separated in -ts; they will be expanded to multiple --tests flags.
|
||||
EOF
|
||||
}
|
||||
|
||||
@@ -45,21 +45,41 @@ if [[ $# -eq 0 ]]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
while getopts ":o:s:d:t:h" opt; do
|
||||
case "$opt" in
|
||||
o) ORG="$OPTARG" ;;
|
||||
s) IFS=',' read -r -a SOURCES_ARR <<< "$OPTARG" ;;
|
||||
d) DIR_PATH="$OPTARG" ;;
|
||||
t) IFS=',' read -r -a TESTS_ARR <<< "$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
|
||||
-to|--target-org)
|
||||
ORG="$2"
|
||||
shift 2
|
||||
;;
|
||||
-sr|--sources)
|
||||
IFS=',' read -r -a SOURCES_ARR <<< "$2"
|
||||
shift 2
|
||||
;;
|
||||
-dr|--directory)
|
||||
DIR_PATH="$2"
|
||||
shift 2
|
||||
;;
|
||||
-ts|--tests)
|
||||
IFS=',' read -r -a TESTS_ARR <<< "$2"
|
||||
shift 2
|
||||
;;
|
||||
-hp|--help)
|
||||
show_help
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
echo "Unknown option: $1" >&2
|
||||
echo
|
||||
show_help
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# Validate that either -s or -d is provided, but not both
|
||||
# Validate that either -sr or -dr is provided, but not both
|
||||
if [[ -n "$DIR_PATH" && ${#SOURCES_ARR[@]} -gt 0 ]]; then
|
||||
echo "Error: Cannot use both -s and -d options. Use -s for specific files or -d for directories." >&2
|
||||
echo "Error: Cannot use both -sr and -dr options. Use -sr for specific files or -dr for directories." >&2
|
||||
echo
|
||||
show_help
|
||||
exit 1
|
||||
@@ -67,7 +87,7 @@ fi
|
||||
|
||||
# Validate that at least one source option is provided
|
||||
if [[ -z "$DIR_PATH" && ${#SOURCES_ARR[@]} -eq 0 ]]; then
|
||||
echo "Error: Must provide either -s (specific files) or -d (directory path)." >&2
|
||||
echo "Error: Must provide either -sr (specific files) or -dr (directory path)." >&2
|
||||
echo
|
||||
show_help
|
||||
exit 1
|
||||
|
||||
Reference in New Issue
Block a user