Skip to content

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

Merged
joshjohanning merged 2 commits intomainfrom
add-helper-text-to-pr-script
Apr 15, 2026
Merged

feat(help): add detailed usage instructions and help flag to merge-pull-requests-by-title.sh#164
joshjohanning merged 2 commits 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 thread gh-cli/merge-pull-requests-by-title.sh
Comment thread gh-cli/merge-pull-requests-by-title.sh
Update help text to note that --bump-patch-version only bumps/commits/pushes
and does not merge PRs unless combined with --enable-auto-merge.
@joshjohanning joshjohanning merged commit 18c5c77 into main Apr 15, 2026
6 checks passed
@joshjohanning joshjohanning deleted the add-helper-text-to-pr-script branch April 15, 2026 19:42
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