Skip to content

Add optional TOML config file support via --config flag#112

Open
aufam wants to merge 3 commits into
asciinema:mainfrom
aufam:main
Open

Add optional TOML config file support via --config flag#112
aufam wants to merge 3 commits into
asciinema:mainfrom
aufam:main

Conversation

@aufam
Copy link
Copy Markdown

@aufam aufam commented Apr 20, 2026

Hello, thanks for making this awesome project.

I frequently find myself running agg with the same set of flags over and over. So I figured a config file would be a nice quality-of-life improvement.

This PR adds support for an optional TOML configuration file, making it easy to persist preferred settings in one place.

Usage

# Explicit config path
agg --config path/to/agg.toml input.cast output.gif

# Auto-detected from default config directory (no flag needed)
agg input.cast output.gif

# CLI flags still override config values
agg --speed 2.0 input.cast output.gif

If --config is not specified, agg will look for agg.toml in the user's config directory (via the dirs crate):

If no config file is found, everything works exactly as before — no breaking changes.

Priority order

CLI arguments > config file > default values

Explicitly passed CLI flags always win. The --help output continues to display default values as before.

Config file format

The config struct mirrors agg::Config and uses kebab-case keys:

font-family = "JetBrains Mono"
font-size = 14
line-height = 1.4
speed = 1.0
no-loop = false
idle-time-limit = 5.0
fps-cap = 30
last-frame-duration = 1.0

Changes

  • Added --config CLI flag
  • Added TOML config file parsing via serde and toml crates
  • Added dirs crate for resolving the default config directory

Happy to adjust anything — thanks for your time reviewing!

aufam added 3 commits April 20, 2026 15:32
Load configuration from a TOML file. The `agg.toml` file will be searched for in the
user's config directory if no explicit path is provided via the `--config` flag.
Command-line arguments override TOML configurations. The `#[serde(skip_deserializing)]`
attribute is used on the `Theme` enum to prevent deserialization issues.
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.

1 participant