Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow storing config in Cargo.toml #241

Open
alerque opened this issue Oct 13, 2024 · 4 comments
Open

Allow storing config in Cargo.toml #241

alerque opened this issue Oct 13, 2024 · 4 comments

Comments

@alerque
Copy link

alerque commented Oct 13, 2024

Cargo manifests have a standardized way to store TOML data that configures third party tooling. The [package.metadata.bacon] space in Cargo.toml could be used to hold Bacon configs instead of a stand alone bacon.toml file. This is supported by many developer tools that are used in Rust or Rust adjacent projects, e.g. ruff, typos, git-cliff, and many more.

Obviously this should be optional, but checking that key in the manifest for config data in addition to the default stand alone config location would be appreciated by projects that already have enough clutter in the project root file space and prefer to group tooling configs together.

@Canop
Copy link
Owner

Canop commented Oct 14, 2024

Interesting.

A problem is the bacon.toml file is neither small nor flat. This would probably be quite ugly.

Also, the need to prefix all keys would make it harder to copy paste between config files.

Did you try writing a Cargo.toml file with bacon config inside to see how it would look ?

@alerque
Copy link
Author

alerque commented Oct 14, 2024

Yes I am aware of exactly how it would look, and yes the extra prefix to the namespace adds verbosity. But "that would be ugly" sees like a subjective metric that should be left up to the end user. I'm not suggesting making it the default or taking away the current stand alone config option. I work on projects that go both ways and there are pros and cons for both. As far as Bacon's side goes all you have to do is load the TOML and query the correct namespace, then remove the prefix from everything. It shouldn't be too much trouble to implement or maintain and it lets projects manage their tooling however they want to along with many other tools that work the same way.

@Canop
Copy link
Owner

Canop commented Oct 14, 2024

It shouldn't be too much trouble to implement

Exact.

then remove the prefix from everything

This won't be necessary if the TOML file is deserialized into the right struct.

Can you build a complete example file to serve as example and as test ?

@alerque
Copy link
Author

alerque commented Nov 19, 2024

Currently working bacon.toml:

default_job = "build"

[jobs.build]
command = [
  "cargo", "build",
  "--features", "luajit",
  "--color", "always"
]

Proposed lines to enable the same behavior in Cargo.toml:

[package.metadata.bacon]
default_job = "build"

[package.metadata.bacon.jobs.build]
command = [
  "cargo", "build",
  "--features", "luajit",
  "--color", "always"
]

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

No branches or pull requests

2 participants