feat(help): add detailed usage instructions and help flag to merge-pull-requests-by-title.sh#164
feat(help): add detailed usage instructions and help flag to merge-pull-requests-by-title.sh#164joshjohanning wants to merge 1 commit intomainfrom
Conversation
…ll-requests-by-title.sh
There was a problem hiding this comment.
Pull request overview
Adds a dedicated --help/-h flow to gh-cli/merge-pull-requests-by-title.sh so users can discover supported invocation modes, positional args, and flags directly from the script.
Changes:
- Introduces a
print_help()function with detailed usage/flags/examples - Adds
-h/--helphandling to exit early after printing help - Replaces the “too few args” usage block with a
print_helpcall
Comments suppressed due to low confidence (1)
gh-cli/merge-pull-requests-by-title.sh:154
- The argument parser only errors on unknown long options (
--*). With-hnow supported, other unknown short options (e.g.,-x) will be treated as positional args and can lead to confusing failures later. Consider explicitly rejecting unknown-*flags (or supporting--end-of-options) and showing the valid flags/help output.
while [ $i -lt ${#args[@]} ]; do
arg="${args[$i]}"
if [ "$arg" = "--help" ] || [ "$arg" = "-h" ]; then
print_help
exit 0
elif [ "$arg" = "--dry-run" ]; then
dry_run=true
elif [ "$arg" = "--bump-patch-version" ]; then
bump_patch_version=true
elif [ "$arg" = "--enable-auto-merge" ]; then
enable_auto_merge=true
elif [ "$arg" = "--no-prompt" ]; then
no_prompt=true
elif [ "$arg" = "--owner" ]; then
((i++))
search_owner="${args[$i]}"
if [ -z "$search_owner" ] || [[ "$search_owner" == --* ]]; then
echo "Error: --owner requires a value"
exit 1
fi
if ! [[ "$search_owner" =~ ^[a-zA-Z0-9._-]+$ ]]; then
echo "Error: Invalid owner '$search_owner' - must be a valid GitHub username or organization"
exit 1
fi
elif [ "$arg" = "--topic" ]; then
((i++))
topic_val="${args[$i]}"
if [ -z "$topic_val" ] || [[ "$topic_val" == --* ]]; then
echo "Error: --topic requires a value"
exit 1
fi
topics+=("$topic_val")
elif [[ "$arg" == --* ]]; then
echo "Error: Unknown flag '$arg'"
echo "Valid flags: ${valid_flags[*]}"
exit 1
fi
| echo "Flags:" | ||
| echo " -h, --help - Show this help message and exit" | ||
| echo " --topic <topic> - Filter --owner repositories by topic (can be specified multiple times)" | ||
| echo " --dry-run - Preview what would be merged without actually merging" | ||
| echo " --bump-patch-version - Clone each matching PR branch, run npm version patch, commit, and push" | ||
| echo " --enable-auto-merge - Enable auto-merge on matching PRs" | ||
| echo " --no-prompt - Merge without interactive confirmation" |
There was a problem hiding this comment.
--bump-patch-version help text omits a key behavioral detail: when this flag is used without --enable-auto-merge, the script only bumps/commits/pushes and does not merge PRs. Updating the help output to mention this would prevent users from assuming a merge will happen.
| valid_flags=("-h" "--help" "--dry-run" "--bump-patch-version" "--enable-auto-merge" "--no-prompt" "--owner" "--topic") | ||
| args=("$@") | ||
| i=0 | ||
| while [ $i -lt ${#args[@]} ]; do | ||
| arg="${args[$i]}" | ||
| if [ "$arg" = "--dry-run" ]; then | ||
| if [ "$arg" = "--help" ] || [ "$arg" = "-h" ]; then | ||
| print_help | ||
| exit 0 | ||
| elif [ "$arg" = "--dry-run" ]; then |
There was a problem hiding this comment.
This PR adds new user-facing input flags (-h/--help). The gh-cli/README.md section for this script currently doesn’t mention the help option; please update the README entry to reflect the new flag so usage docs stay in sync.
Adding a
--helpflag to help with input options