Skip to content

feat(cli): config file resolution + command split#85

Merged
Sootopolis merged 1 commit into
mainfrom
feat/43-cli-config
Jun 17, 2026
Merged

feat(cli): config file resolution + command split#85
Sootopolis merged 1 commit into
mainfrom
feat/43-cli-config

Conversation

@Sootopolis

Copy link
Copy Markdown
Owner

Closes #43.

What

The ccas CLI now reads optional settings from ${XDG_CONFIG_HOME:-~/.config}/ccas/config.conf:

api_url       = "http://127.0.0.1:8080"
default_clubs = ["team-alpha", "team-beta"]
log_dir       = "~/.local/state/ccas/logs"   # reserved; parsed, not yet used
  • Server URL resolves --server <url> flag → config api_url → built-in http://127.0.0.1:8080.
  • default_clubs seeds the completion clubs.txt on a fresh install (mtime stamped to epoch so the next server command still refreshes authoritative slugs).
  • Missing file → built-in defaults (no crash). Malformed file → error: invalid config file <path>: … (exit 2).

Decisions (diverge from the issue, with sign-off)

  • HOCON config.conf, not TOML — reuses typesafe-config already in the tree via zio-config TypesafeConfigProvider.fromHoconFileZIO; no new dependency. (.toml.conf is the only issue-text deviation.)
  • Scope kept minimal — the issue's default_clubs-as-slug-fallback (a list; 2+ → error every call) was deliberately not built; a follow-up issue will design club-context (current_club + ccas use <slug>) which supersedes it.

Refactor folded in

Split CliCommand into ServerCommand (HTTP-client subcommands that carry the resolved server URL) vs local commands (Serve — now a case object with no --server; Completion). Removes the Completion.server = "" sentinel and the dead Serve/Completion branches in Dispatcher; Dispatcher.dispatch/runCommand now take ServerCommand so cmd.server is always real. Regenerated completions/ccas.bash.

Test plan

  • sbt test → 797 passed (new TestCliConfig; resolution-order cases in TestCliParser; TestCcasCompletion byte-equality after regen).
  • Staged-binary manual checks: missing config → defaults; config api_url used; --server overrides; malformed → clean exit 2; default_clubs seeds clubs.txt; serve --help no longer lists --server.

🤖 Generated with Claude Code

Read optional ~/.config/ccas/config.conf (HOCON via zio-config). Server URL
resolves --server flag > config api_url > built-in http://127.0.0.1:8080;
default_clubs seeds the shell-completion cache; log_dir is parsed but not yet
used. Missing file falls back to defaults; a malformed file fails fast with a
file-naming error (exit 2).

HOCON/config.conf instead of the issue's config.toml — reuses typesafe-config
already in the dependency tree, so no new dependency.

Split CliCommand into ServerCommand (HTTP-client subcommands carrying the
resolved server URL) and local commands (Serve, now a case object with no
--server; Completion). Removes the Completion server="" sentinel and the dead
dispatcher branches; regenerated completions/ccas.bash.

Closes #43

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@Sootopolis Sootopolis merged commit 91fcca0 into main Jun 17, 2026
1 check passed
@Sootopolis Sootopolis deleted the feat/43-cli-config branch June 17, 2026 15:11
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 config file resolution

1 participant