KEMBAR78
Prefer a less-generic config file `sws.toml` as default and keep the old `config.toml` temporarily by davlgd · Pull Request #551 · static-web-server/static-web-server · GitHub
Skip to content

Conversation

@davlgd
Copy link
Contributor

@davlgd davlgd commented Jul 1, 2025

This PR tends to fix #550

Description

It changes default config file name to sws_config.toml to avoid conflicts. Docs/tests are updated accordingly, if you prefer I can create dedicated commits for that.

Related Issue

#550

Motivation and Context

We use Zola and potentially other projects already using a config.toml file as default. When we launch the project, there is unwanted logs as sws use the zola config.toml as its own.

Another solution could be to not read/use config.toml file not valid for SWS, but I think it's better to avoid such generic file name. And the sooner the better on such change.

Feel free to close this if you prefer to continue with the current file name and go for another solution.

How Has This Been Tested?

I've build the project and used it with a sws_config.toml without env var or flag to point it. It was perfectly loaded and used.

Screenshots (if appropriate):

@semanticdiff-com
Copy link

semanticdiff-com bot commented Jul 1, 2025

Review changes with  SemanticDiff

Changed Files
File Status
  src/settings/mod.rs  15% smaller
  docs/content/configuration/command-line-arguments.md Unsupported file format
  docs/content/configuration/config-file.md Unsupported file format
  docs/content/features/docker.md Unsupported file format
  docs/content/features/windows-service.md Unsupported file format
  src/settings/cli.rs  0% smaller
  src/settings/file.rs  0% smaller
  tests/settings.rs  0% smaller
  tests/toml/sws.toml Unsupported file format

@joseluisq
Copy link
Collaborator

Hey @davlgd, based on #550 (comment).

Here are some steps you can take:

  • Use sws.toml as the default value in the cli.rs file.
  • Check for the old config.toml file at start-up, if it exists, then use that config.
  • Otherwise, if the old config.toml does not exist, then check for sws.toml (default behaviour).

Let me know your thoughts on that.

@davlgd davlgd force-pushed the davlgd-default-config-file branch from 655973b to fdb0bcf Compare July 1, 2025 16:40
@davlgd
Copy link
Contributor Author

davlgd commented Jul 1, 2025

@joseluisq I've made the change as asked. Feel free to update warning message

- sws.toml used if present
- config.toml has priority
- A warning message is printed if config.toml is used
@davlgd davlgd force-pushed the davlgd-default-config-file branch from fdb0bcf to c2f1934 Compare July 1, 2025 18:03
@joseluisq joseluisq added enhancement New feature or request v2 v2 release labels Jul 2, 2025
@joseluisq joseluisq changed the title feat: change default config file (sws_config.toml) Prefer a less-generic config file sws.toml as default and keep the old config.toml temporarily Jul 2, 2025
Comment on lines -227 to +235
// Handle "config file options" and set them when available
// NOTE: All config file based options shouldn't be mandatory, therefore `Some()` wrapped
if let Some((settings, config_file_resolved)) = read_file_settings(&opts.config_file)? {
let to_use_config_file = match Path::new("./config.toml").is_file() {
true => {
eprintln!("Deprecated: 'config.toml' found, rename it to 'sws.toml' to prepare for future releases");
PathBuf::from("./config.toml")
}
false => opts.config_file.clone(),
};

if let Some((settings, config_file_resolved)) = read_file_settings(&to_use_config_file)? {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a comment for me to remove that check later in a future release.

Copy link
Collaborator

@joseluisq joseluisq left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks fine to me.
I will take care of the CI warnings.

Thanks!

@joseluisq joseluisq merged commit acd8388 into static-web-server:master Jul 2, 2025
35 of 36 checks passed
@davlgd davlgd deleted the davlgd-default-config-file branch July 2, 2025 09:17
@joseluisq joseluisq added this to the v2.38.0 milestone Jul 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request v2 v2 release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use a less generic default config file name

2 participants