Skip to content

feat: add dotfile-based option defaults for CliApp (#191)#558

Open
Flamki wants to merge 4 commits intozio:masterfrom
Flamki:feat/cli-config-files-191
Open

feat: add dotfile-based option defaults for CliApp (#191)#558
Flamki wants to merge 4 commits intozio:masterfrom
Flamki:feat/cli-config-files-191

Conversation

@Flamki
Copy link
Copy Markdown

@Flamki Flamki commented Mar 26, 2026

Implements support for reading CLI option defaults from per-app dotfiles.

Fixes #191
/claim #191

What this adds

  • Resolves .<app-name> files from:
    1. user home directory (lowest priority)
    2. parent directories from filesystem root down to cwd
    3. current working directory (highest file priority)
  • Parses supported config lines:
    • --key=value
    • --key value
    • --flag
    • ignores empty lines and # comments
  • Merges file options with CLI args so CLI always wins
  • Prints applied config values and source files
  • Keeps built-in command behavior stable (--help, --wizard, completion paths)

Implementation

  • New config engine in zio.cli.config:
    • ConfigFileResolver
    • ConfigParser
    • ConfigMerger
    • ConfigDiagnostics
  • Platform-specific resolvers:
    • JVM + Native implementations
    • JS no-op implementation
  • CliApp.run integration point before command.parse
  • Help + docs update for config-file behavior

Tests

Added:

  • zio.cli.config.ConfigParserMergerSpec
  • zio.cli.config.ConfigFileResolverSpec (JVM integration)

Validated locally:

  • zioCliJVM/testOnly zio.cli.config.ConfigParserMergerSpec zio.cli.config.ConfigFileResolverSpec
  • scalafmtCheckAll
  • zioCliJS/compile
  • zioCliNative/compile

Notes

  • This PR intentionally avoids changing core option/command parser contracts.
  • I can attach a short demo video in a follow-up comment if maintainers want it attached directly in PR discussion.

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Mar 26, 2026

CLA assistant check
All committers have signed the CLA.

@Flamki
Copy link
Copy Markdown
Author

Flamki commented Mar 26, 2026

Updated demo video (fullscreen terminal, clean capture, no recorder UI):

https://github.com/Flamki/zio-cli/releases/download/demo-191-video/pr-558-demo-fullscreen-20260326-190242.mp4

This run shows:

  • feature branch + commit summary
  • key config-file implementation references
  • target specs passing (ArgumentCollisionSpec, ConfigParserMergerSpec, ConfigFileResolverSpec)
  • PR metadata (gh pr view 558)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for reading command-line options from file(s)

2 participants