Skip to content

refactor(cli): split cmdPull and share the login step with push - #59

Merged
CameronBrooks11 merged 2 commits into
mainfrom
refactor/cmd-pull
Nov 13, 2026
Merged

CameronBrooks11 merged 2 commits into
mainfrom
refactor/cmd-pull

Conversation

@CameronBrooks11

Copy link
Copy Markdown
Member

Two commits:

  1. Tests that pin pull's output. main_test.go checked exit codes only. TestPullOutput runs pull against a small fake wiki and compares stdout, stderr and the exit code for every kind of report line:

    • categories walked
    • refresh
    • pulled
    • local edit
    • missing page
    • filename collision
    • watchlist login and missing titles
    • translations left out
    • empty selection

    TestLoginNeedsCredentials and a stderr check in TestPullWatchlistLogsInFirst pin the login messages of both pull and push.

  2. The refactor.

    • login() replaces the credential lookup and login that cmdPull and cmdPush each had.
    • printPullReport() takes the report lines and the exit code.
    • PullReport.Total() replaces the outcome count that was written out twice.

    cmdPull goes from 105 to 68 lines.

All three tests pass on the code before and after the refactor. Dropping Missing from Total() makes TestPullOutput fail with an extra no pages matched.

No change to output or exit codes.

Closes #49

main_test checked exit codes only. TestPullOutput runs pull against a
small fake wiki and compares stdout, stderr and the exit code for each
kind of report line: categories walked, a refresh, pulled pages, local
edits, missing pages, filename collisions, the watchlist login and its
missing titles, translations left out, and an empty selection.
cmdPull was 105 lines. The credential lookup and login it shared with
cmdPush are now login(); the report lines and exit code are
printPullReport(); PullReport.Total() replaces the outcome count that
was written out twice. cmdPull is 68 lines.

Output and exit codes are unchanged: TestPullOutput,
TestLoginNeedsCredentials and the login failure check in
TestPullWatchlistLogsInFirst pass on the code before and after.

Closes #49
@CameronBrooks11
CameronBrooks11 merged commit 4750d5d into main Nov 13, 2026
9 checks passed
@CameronBrooks11
CameronBrooks11 deleted the refactor/cmd-pull branch November 13, 2026 17:24
CameronBrooks11 added a commit that referenced this pull request Nov 13, 2026
Prepares v0.5.1: the version constant becomes 0.5.1, and the CHANGELOG's
Unreleased section becomes 0.5.1. User-facing changes since v0.5.0: #52
(HTTP status on login and edit errors, #45), #53 (conflict check reads
the revision id only, #46), #61 (login failure and count wording, #56),
#62 (push read-back warning, #58). The rest are refactors with no change
in behaviour: #54, #55, #57, #59, #60. The tag is pushed after this
merges.
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.

cli: split cmdPull and share the login step with push

1 participant