Move the command line from cmd/bsdaily into internal/cli (closes #8) #13

Open
clawbot wants to merge 1 commits from issue-8-cli-into-internal into next
Collaborator

cmd/bsdaily/main.go is now a single call, os.Exit(cli.Main(Version)), as REPO_POLICIES.md asks of cmd/. Version stays in package main, where -X main.Version sets it.

The cobra command, the flag rules and the date parsing moved as they were into a new package, internal/cli: cli.go holds Main (logger setup, the command and its flags) and dates.go holds ParseTargetDates and its errors. Flags, help text, error messages, exit status and the first log line with the version are unchanged.

dates_test.go has two table tests of ParseTargetDates: one for accepted flags (none, a single date, a range across a month end, a range of one day) and one for rejected ones (--from after --to, either half of a range missing, --date with --from and with both, malformed and nonexistent dates). They never touch the filesystem or run the extraction.

The README (How It Works) now says which part lives where; TODO.md records the step and narrows Next Step to the internal/bsdaily tests.

  • Judgement call: parseTargetDates is exported as ParseTargetDates so the tests, in package cli_test, use only what the package exposes.
  • Judgement call: the fallback to dev for an empty version moved from main into cli.Main, so main holds only the one call.
  • Judgement call: for a malformed date the tests check how the message starts, not the date parser's own wording that follows it.
  • Unverified: the dev fallback was not run through a built binary; every build here carries a version.

Model: opus-5-5

`cmd/bsdaily/main.go` is now a single call, `os.Exit(cli.Main(Version))`, as `REPO_POLICIES.md` asks of `cmd/`. `Version` stays in package `main`, where `-X main.Version` sets it. The cobra command, the flag rules and the date parsing moved as they were into a new package, `internal/cli`: `cli.go` holds `Main` (logger setup, the command and its flags) and `dates.go` holds `ParseTargetDates` and its errors. Flags, help text, error messages, exit status and the first log line with the version are unchanged. `dates_test.go` has two table tests of `ParseTargetDates`: one for accepted flags (none, a single date, a range across a month end, a range of one day) and one for rejected ones (`--from` after `--to`, either half of a range missing, `--date` with `--from` and with both, malformed and nonexistent dates). They never touch the filesystem or run the extraction. The README (How It Works) now says which part lives where; `TODO.md` records the step and narrows Next Step to the `internal/bsdaily` tests. - Judgement call: `parseTargetDates` is exported as `ParseTargetDates` so the tests, in package `cli_test`, use only what the package exposes. - Judgement call: the fallback to `dev` for an empty version moved from `main` into `cli.Main`, so `main` holds only the one call. - Judgement call: for a malformed date the tests check how the message starts, not the date parser's own wording that follows it. - Unverified: the `dev` fallback was not run through a built binary; every build here carries a version. Model: opus-5-5
clawbot added the needs-review label 2026-10-06 20:05:09 +02:00
clawbot self-assigned this 2026-10-06 20:05:09 +02:00
clawbot added 1 commit 2026-10-06 20:05:10 +02:00
cmd/bsdaily/main.go now only passes Version to cli.Main and exits with
the status it returns, as REPO_POLICIES.md requires of cmd/. The cobra
command, the flag rules and the date parsing moved unchanged into
internal/cli, so flags, help text, error messages, exit status and the
first log line stay as they were. The fallback to dev for an empty
version moved with them into cli.Main.

parseTargetDates is exported as ParseTargetDates so that a table test
outside the package can reach it; the test never touches the filesystem
or runs the extraction. README describes the new layout and TODO.md
records the step.

Model: opus-5-5
Author
Collaborator

Review failed.

  1. internal/cli/dates_test.go line 104: every error case checks only how the message starts, including the four whose whole text is fixed (--from requires --to, --to requires --from, --date and --from/--to are mutually exclusive, --from … is after --to …). Text added to the end of any of these messages still passes, although #8 requires the error messages to stay as they are. Acceptable: compare those four messages in full, and keep the start-only match for the malformed-date cases, where the date parser's own wording follows.
  2. internal/cli/dates_test.go, the error table (lines 66-97): --date together with --to alone has no case, so the rule that --date excludes --from/--to is tested only for --from. Acceptable: add a --date with --to case that expects the mutually-exclusive message.
  3. TODO.md line 27: the new Completed Steps entry is followed by a blank line, the only one in that list. This makes the whole list loose, so every entry renders as its own paragraph. Acceptable: no blank line, like the other entries.

Model: opus-5-5

Review failed. 1. `internal/cli/dates_test.go` line 104: every error case checks only how the message starts, including the four whose whole text is fixed (`--from requires --to`, `--to requires --from`, `--date and --from/--to are mutually exclusive`, `--from … is after --to …`). Text added to the end of any of these messages still passes, although https://git.eeqj.de/sneak/bsdaily/issues/8 requires the error messages to stay as they are. Acceptable: compare those four messages in full, and keep the start-only match for the malformed-date cases, where the date parser's own wording follows. 2. `internal/cli/dates_test.go`, the error table (lines 66-97): `--date` together with `--to` alone has no case, so the rule that `--date` excludes `--from`/`--to` is tested only for `--from`. Acceptable: add a `--date` with `--to` case that expects the mutually-exclusive message. 3. `TODO.md` line 27: the new Completed Steps entry is followed by a blank line, the only one in that list. This makes the whole list loose, so every entry renders as its own paragraph. Acceptable: no blank line, like the other entries. Model: opus-5-5
clawbot added needs-rework and removed needs-review labels 2026-10-06 21:05:51 +02:00
Some checks are pending
check / check (push) Waiting to run
You are not authorized to merge this pull request.
This pull request can be merged automatically.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin issue-8-cli-into-internal:issue-8-cli-into-internal
git checkout issue-8-cli-into-internal
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sneak/bsdaily#13