Skip to content

Add configuration file support with --init flag - #84

Merged
Boomatang merged 3 commits into
mainfrom
16-configuration-file
Aug 1, 2026
Merged

Add configuration file support with --init flag#84
Boomatang merged 3 commits into
mainfrom
16-configuration-file

Conversation

@Boomatang

@Boomatang Boomatang commented Jul 19, 2026

Copy link
Copy Markdown
Owner

Closes #16

Summary

Adds support for a ZON-based configuration file so users can set default behavior (clone path, clone mode, shallow clones, log level) without repeating CLI flags or relying on environment variables.

A new --init flag generates a default configuration file at the XDG-compliant location. On startup, the configuration file is loaded and its values are applied, with CLI flags and environment variables taking precedence.

Precedence

Settings are resolved in the following order (most specific wins):

CLI flags > Environment variables (GRAB_PATH) > Config file > Built-in defaults

Acceptance Criteria

  • File format: Configuration uses ZON (Zig Object Notation), parsed natively with std.zon.parse -- no external dependencies needed.
  • File location: Follows XDG Base Directory specification -- checks $XDG_CONFIG_HOME/grab/config.zon first, falls back to $HOME/.config/grab/config.zon.
  • Settings: All four settings from the spec are supported: path, action, shallow, and log_level, with the specified types and defaults.
  • Example config: The generated default config file includes all settings with comments explaining each option, and path is commented out so it defaults to null.
  • Precedence: CLI flags override environment variables, which override config file values, which override built-in defaults.
  • Creation: grab --init generates a config file with defaults. If the file already exists, it warns and exits without overwriting.
  • Error handling: Invalid ZON in the config file produces a parse error and halts execution -- no silent fallback to defaults.
  • No config file: The config file is entirely optional. Without one, the tool behaves exactly as before.

@Boomatang
Boomatang force-pushed the 16-configuration-file branch from 91ebd7f to cd1add0 Compare July 19, 2026 20:04
@Boomatang Boomatang changed the title ADD: Configuration File Add configuration file support with --init flag Jul 19, 2026
Configuration File is now created.
Currently is still not being used.

Signed-off-by: Jim Fitzpatrick <jimfity@gmail.com>
@Boomatang
Boomatang force-pushed the 16-configuration-file branch from a08c3d6 to 00d1cbf Compare August 1, 2026 14:26
Did some clean up in the code base.
Switched branch.autoSetupMerge to true.

Signed-off-by: Jim Fitzpatrick <jimfity@gmail.com>
@Boomatang
Boomatang force-pushed the 16-configuration-file branch from 00d1cbf to ccd7878 Compare August 1, 2026 14:32
Signed-off-by: Jim Fitzpatrick <jimfity@gmail.com>
@Boomatang
Boomatang marked this pull request as ready for review August 1, 2026 15:21
@Boomatang
Boomatang merged commit c781946 into main Aug 1, 2026
2 checks passed
@Boomatang Boomatang mentioned this pull request Aug 1, 2026
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.

Configuration file

1 participant