Skip to content

feat(help): add detailed usage instructions and help flag to merge-pull-requests-by-title.sh#164

Open
joshjohanning wants to merge 1 commit intomainfrom
add-helper-text-to-pr-script
Open

feat(help): add detailed usage instructions and help flag to merge-pull-requests-by-title.sh#164
joshjohanning wants to merge 1 commit intomainfrom
add-helper-text-to-pr-script

Conversation

@joshjohanning
Copy link
Copy Markdown
Owner

Adding a --help flag to help with input options

Copilot AI review requested due to automatic review settings March 30, 2026 19:11
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 / --help handling to exit early after printing help
  • Replaces the “too few args” usage block with a print_help call
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 -h now 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

Comment on lines +89 to +95
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"
Copy link

Copilot AI Mar 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

--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.

Copilot uses AI. Check for mistakes.
Comment on lines +115 to +123
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
Copy link

Copilot AI Mar 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot generated this review using guidance from repository custom instructions.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants