Skip to content

refactor(scrape): adopt kit/console/cli + conventions parity#5

Merged
jadb merged 3 commits into
mainfrom
cli-parity-foo-scrape
Jun 17, 2026
Merged

refactor(scrape): adopt kit/console/cli + conventions parity#5
jadb merged 3 commits into
mainfrom
cli-parity-foo-scrape

Conversation

@jadb

@jadb jadb commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Migrates the foo-scrape sidecar from a hand-rolled os.Args parser to kit/console/cli, resolving the red-verdict findings from the CLI review.

Changes

  • kit/console/cli root — replace the hand-rolled argument loop with a cobra root via cli.New. <url> becomes a positional. Brings the kit-owned globals (--version, --quiet, --no-color, --format, -V, -C, --help-all) for free.
  • --mode enum — replace the mutually-overriding --readability / --raw booleans with --mode <readability|raw> (default readability), validated.
  • Exit codes — usage / bad-flag / bad-mode now exit 2.
  • Drop the dead io import + io.Discard suppression hack.
  • Events — publish foo-scrape.capture.page.scraped after a successful scrape; failed scrapes publish nothing. Network adapter tolerant of connect failure.

Contract preserved

  • --ext-info still emits the exact four-field discovery JSON (name, version, description, capabilities), exit 0 — the host's plugin discovery depends on it.

Verification

  • go build ./... + go vet ./cmd/foo-scrape/... clean.
  • ext-info, --help, --mode validation, and exit codes probed.

Copilot AI review requested due to automatic review settings June 16, 2026 16:27

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

jadb added 3 commits June 17, 2026 01:31
replace hand-rolled os.Args switch with cli.New root
single-shot leaf: <url> positional, ExactArgs(1)
kit globals for free (--version --quiet --no-color --format -V -C --help-all)
--ext-info intercepted pre-cobra, four-field discovery contract intact
side-effect=read, idempotent=yes annotations
usage/bad-flag exit 2 via output.UsageError envelope
drop dead io.Discard import hack
drop --readability/--raw boolean pair
add --mode <readability|raw>, default readability
validate enum in RunE, reject unknown value as usage error (exit 2)
wire in-process kitbus.New + NetworkAdapter (source foo-scrape).
peers from FOO_SCRAPE_BUS_PEERS; auth FOO_BUS_TOKEN/BUS_TOKEN.
publish foo-scrape.capture.page.scraped {url, mode} on success.
connect failures warn-logged, never fatal; no --offline flag.
ext-info contract + exit codes unchanged.
@jadb jadb force-pushed the cli-parity-foo-scrape branch from d1769b1 to 7da62d6 Compare June 17, 2026 05:32
@jadb jadb merged commit 4b7816c into main Jun 17, 2026
2 checks passed
@jadb jadb deleted the cli-parity-foo-scrape branch June 17, 2026 05:38
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