Crate ghl

Crate ghl 

Source
Expand description

List and optionally batch‑merge GitHub pull requests interactively, or create issues with associated branches.

Provides a colorized TUI to select multiple PRs then apply a composite operation (approve & merge, Dependabot rebase, enable auto-merge). Alternatively, create a GitHub issue and an associated branch from the default branch. Mirrors the run() pattern used by gch so the binary main stays trivial.

§Flow

  • Parse flags (--search, --merge-state, issue).
  • If issue is present:
    • Prompt for issue title via [ytil_tui::text_prompt].
    • Prompt for whether to checkout the branch via [ytil_tui::yes_no_select].
    • Create issue via [ytil_gh::issue::create].
    • Develop the issue via [ytil_gh::issue::develop] (creates branch and optionally checks it out).
  • Otherwise:
    • Detect current repository via [ytil_gh::get_repo_view_field].
    • Fetch PR list via [ytil_gh::pr::get] (GitHub CLI gh pr list) forwarding the search filter.
    • Apply optional in‑process merge state filter.
    • Present multi‑select TUI via [ytil_tui::minimal_multi_select].
    • Execute chosen high‑level operation over selected PRs, reporting per‑PR result.

§Flags

  • --search <FILTER> or --search=<FILTER>: forwarded to gh pr list --search. Optional.
  • --merge-state <STATE> or --merge-state=<STATE>: client‑side filter over fetched PRs. Accepted (case‑insensitive) values for [PullRequestMergeState]: Behind|Blocked|Clean|Dirty|Draft|HasHooks|Unknown|Unmergeable|Unstable.
  • issue: switch to issue creation mode (prompts for title, creates issue and branch).

Use -- to terminate flag parsing (subsequent arguments ignored by this tool).

§Usage

ghl # list all open PRs interactively
ghl --search "fix ci" # filter by search terms
ghl --merge-state Clean # filter by merge state only
ghl --search="lint" --merge-state Dirty # combine search + state (supports = or space)
ghl issue # create issue and branch interactively

§Errors

  • Flag parsing fails (unknown flag, missing value, invalid [PullRequestMergeState]).
  • GitHub CLI invocation fails (listing PRs via [ytil_gh::pr::get], approving via [ytil_gh::pr::approve], merging via [ytil_gh::pr::merge], commenting via [ytil_gh::pr::dependabot_rebase], creating issue via [ytil_gh::issue::create]).
  • TUI interaction fails (selection UI errors via [ytil_tui::minimal_multi_select] and [ytil_tui::minimal_select], issue title prompt via [ytil_tui::text_prompt], branch checkout prompt via [ytil_tui::yes_no_select]).
  • GitHub CLI invocation fails (issue and branch creation via [ytil_gh::issue::create] and [ytil_gh::issue::develop]).

§Future Work

  • Add dry‑run mode printing planned operations without executing.
  • Provide additional bulk actions (labeling, commenting).
  • Introduce structured logging (JSON) for automated auditing.

Structs§

RenderableListedIssue 🔒
RenderablePullRequest
Newtype wrapper implementing colored Display for a [PullRequest].
SelectableOpIter 🔒
An iterator over the variants of SelectableOp

Enums§

Op 🔒
Atomic pull request operations executed by ghl.
SelectableOp 🔒
User-selectable high-level operations to apply to chosen PRs.

Functions§

create_branch_from_issue 🔒
Interactively creates a GitHub branch from a selected issue.
create_issue_and_branch_from_default_branch 🔒
Create a GitHub issue and develop it with an associated branch.
create_pr 🔒
Prompts the selection of a branch and creates a pull request for the selected one.
format_pr 🔒
Format concise identifying PR fields for log / status lines.
main 🔒
List and optionally batch‑merge GitHub pull requests interactively or create issues with associated branches.
pr_title_from_branch_name 🔒
Parses a branch name to generate a pull request title.