Skip to content

overhaul cli flag implementation - #230

Open
ChausseBenjamin wants to merge 2 commits into
shizunge:mainfrom
ChausseBenjamin:flag-overhaul
Open

ChausseBenjamin wants to merge 2 commits into
shizunge:mainfrom
ChausseBenjamin:flag-overhaul

Conversation

@ChausseBenjamin

Copy link
Copy Markdown

The service now uses urfave/cli/v3 to parse cli flags. Every flag (for which it makes sense) can now be configure via either cli, environment variables, or a config toml file. Priority from most important to least important goes as follows:

  1. direct cli flags
  2. environment variables
  3. config file
  4. default values

Just like the existing comments in the codebase outlined, the --help message and the toml config is split into groups:

  • PROXY protocol
  • Prometheus metrics
  • GeoIP
  • Healthcheck
  • Logging

Since environment variables is generally the more idiomatic way of configuring docker-compose infrastructure, the example yaml files now use that syntax. An example config.toml file has also been provided in that same examples/ directory.

The change also deprecates a few flags (marking them as such but still accepting them for backwards compatibility):

  • interval_ms -> interval (which accept any Duration like s, ms, min, etc...)
  • proxy_protocol_read_header_timeout_ms -> proxy_protocol_read_header_timeout (also accepts any Duration)
  • prometheus_clean_unseen_seconds -> prometheus_clean_unseen (also accepts any Duration)
  • enable_prometheus -> prometheus_enabled (was already deprecated but uses scaffolding provided by urfave/cli)

The service now uses urfave/cli/v3 to parse cli flags.
Every flag (for which it makes sense) can now be configure via either
cli, environment variables, or a config `toml` file. Priority from
most important to least important goes as follows:

1. direct cli flags
2. environment variables
3. config file
4. default values

Just like the existing comments in the codebase outlined, the `--help` message
and the `toml` config is split into groups:

- PROXY protocol
- Prometheus metrics
- GeoIP
- Healthcheck
- Logging

Since environment variables is generally the more idiomatic way of configuring
docker-compose infrastructure, the example yaml files now use that syntax.
An example `config.toml` file has also been provided in that same `examples/`
directory.

The change also deprecates a few flags (marking them as such but still accepting
them for backwards compatibility):

- `interval_ms` -> `interval`
  (which accept any *Duration* like `s`, `ms`, `min`, etc...)
- `proxy_protocol_read_header_timeout_ms` -> `proxy_protocol_read_header_timeout`
  (also accepts any *Duration*)
- `prometheus_clean_unseen_seconds` -> `prometheus_clean_unseen`
  (also accepts any *Duration*)
- `enable_prometheus` -> `prometheus_enabled` (was already deprecated but uses
  scaffolding provided by *urfave/cli*)
@ChausseBenjamin
ChausseBenjamin marked this pull request as ready for review September 27, 2026 00:31
@ChausseBenjamin

Copy link
Copy Markdown
Author

A few other things to note:

  • ports now use uint16 (as ports are 16bits) since urfave/cli can parse those and that provides free bounds checking
  • all cli strings are defined as constants so it's harder to make typos if you use those instead of strings to retrieve data from context

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.

2 participants