runsascoded/ghpr#6 Improve help text, refactor command registration, and fix test assertions
This PR includes three improvements to the ghpr codebase:
- Draft flag validation - Added error when using
-dwithout-y, since draft mode is incompatible with web editor - Clearer help text - Updated
createcommand and flag descriptions to clearly explain the three modes:- Default (no
-y): Interactive web editor (waits for user) -yonce: Create via API then view result-yytwice: Create silently
- Default (no
- Auto gist push -
createnow automatically pushes to gist remote after finalizing PR/Issue
Converted all 10 command register() functions from deeply nested function calls to clean vertical decorator stacks:
# Before
cli.command()(
flag('-g', '--gist')(
flag('-n', '--dry-run')(
command
)
)
)
# After
@cli.command()
@flag('-n', '--dry-run')
@flag('-g', '--gist')
def command_cmd(dry_run, gist):
command(gist, dry_run)This makes the code much more readable and maintainable. Net result: -32 lines of code!
Fixed all test assertions across the test suite to use precise equality checks instead of fragile substring matching:
test_import.py- Used regex to extract exact command names from CLI help, fixed shell integration checkstest_create.py- Changed to exact tuple comparisons for gh command arguments, added missing mocks forpush()calltest_files.py- Replaced all substring checks with full content equality, fixed newline handlingtest_gist.py- Replaced substring checks with exact equality, fixed gist footer formatting expectations
Impact: Fixed 51+ problematic assertions that used assert x in y patterns. All 92 tests now pass with precise, maintainable assertions that clearly document expected values