feat(cli): build the ccas subcommand tree (#46)#71
Merged
Merged
Conversation
Turn the `ccas` binary from a serve-only stub into a real CLI: a zio-cli
command tree dispatched as a thin HTTP client to the local CcasServer.
Commands: serve, membership, history, recruit, stats, jobs, logs,
blacklist {add,list,remove}, schedule {list,add,remove}, with a global
--server (default http://127.0.0.1:8080). Each job command submits to the
existing /api routes and polls GET /api/jobs/{id} to completion; exit 0 on
Completed, 1 on Failed/submit-error/unreachable, 2 on usage.
- zio-cli (not decline): ZIO-native, no cats, and built-in shell-completion
generation (towards #49). Bumps zio 2.1.24->2.1.26 and zio-json 0.9.0->0.9.2
to align with zio-cli 0.8.1.
- Wire DTOs reused as the single source of truth: widen the request/response
case classes in JobRoutes/ScheduleRoutes/BlacklistRoutes from private[server]
to private[ccas] so the CLI imports them directly (compile-time drift safety,
no duplication).
- Poll loop is bounded (60-min cap) and treats unknown status as terminal;
unreachable server prints a friendly "start a server with 'ccas serve' first."
Note: zio-cli is POSIX-style (options before positional args); options placed
after a positional are silently dropped/swallowed. Documented in CliCommand's
scaladoc and each --help; follow-up tracked in #70.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #46.
Turns the
ccasbinary from a serve-only stub into a real CLI — a zio-cli command tree dispatched as a thin HTTP client to the localCcasServer.Commands
serve,membership,history,recruit,stats,jobs,logs,blacklist {add,list,remove},schedule {list,add,remove}, with a global--server(defaulthttp://127.0.0.1:8080). Job commands submit to the existing/apiroutes and pollGET /api/jobs/{id}to completion. Exit codes:0Completed,1Failed / submission error / unreachable server,2usage error.Notable decisions
zio 2.1.24→2.1.26,zio-json 0.9.0→0.9.2for zio-cli0.8.1.JobRoutes/ScheduleRoutes/BlacklistRouteswidenedprivate[server]→private[ccas]so the CLI imports them directly (compile-time drift safety, no duplicated codecs).Deferred (forced — need server routes / other issues)
admin ref/clubdata(no routes / would duplicatematchref),__completedynamic completions (#49),config.tomlresolution (#43), live log tail (#47 —logspolls status for now).Verification
sbt testgreen (772/772), incl. all route suites (the DTO visibility widening doesn't break them).TestCliParser,TestJobPoller,TestCcasApiClient(19 tests).--help(exit 0), bad command (exit 2), unreachable server (exit 1, friendly message); bounded e2e against a localccas_testserver — real round-trips, correct exit codes.Known caveat
zio-cli is POSIX-style (options before positional args); options after a positional are silently dropped/swallowed. Documented in
CliCommand's scaladoc and each--help. Follow-up tracked in #70 (unify app + CLI parsing), and an upstream zio-cli issue is drafted.🤖 Generated with Claude Code