-
-
Notifications
You must be signed in to change notification settings - Fork 225
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
feat(Config): Add json config format option #698
Conversation
992ba0f
to
4c22e9b
Compare
In order to make it easier to generate gitit configuration, we add the ability for config files to be json values in addition to the custom config format parser. This should be 100% backward-compatible, with the error messages being reasonably clear about the fallback mechanism. Json strings, numbers and booleans are supported as-is, and the default section also works (sections are distinguished by their name being in `[brackets]`). Potentially a bit more documentation might be needed.
4c22e9b
to
ca08e51
Compare
Have you tested with a json version of the full default config file data/default.conf? |
I would think that the corresponding structure would use |
Hm, I don’t think they are strictly needed, yes. |
Not yet, I did some tests with a subset but I’ll try and see what happens if I convert the whole file. Another thought I had was to allow a subset of jsonc files (i.e. json files with #-comments) by filtering every line that starts with a |
I'm not sure what I think about the proposal. It adds complexity to support an alternative config format, and complexity is, in general, bad. Is the value high enough to outweigh that? Generating a config file that consists of lines with key: value pairs does not seem very difficult and perhaps it's better to put the complexity outside fo gitit itself... |
The biggest complexity here comes from having a non-standard config format imo; json is supported by every editor, with syntax checking and highlighting, can trivially be generated by every config tool (ansible, terraform, nixos …), and can support in-line documentation via a schema definition (vscode will natively look up a "$schema" key and display documentation from the linked schema file for example). It’s a suggestion, I don’t have to necessarily upstream it since my downstream fork is gonna diverge a bunch anyway in the future. |
This is a standard config format, https://en.wikipedia.org/wiki/INI_file , it's just not as popular now as it was when gitit was created. It's also extremely simple, both to parse and to write, and unlike JSON it allows comments, which are highly useful in config file. (Yes, you can use a nonstandard JSON dialect that allows comments, but then you're using a non-standard config format!) If I were creating gitit from scratch, I'd be tempted to use YAML, but I can't change the config format I'm using without breaking backwards compatibility for all existing users. And adding a format to what we have already is a net gain in complexity. |
In order to make it easier to generate gitit configuration, we add the ability for config files to be json values in addition to the custom config format parser.
This should be 100% backward-compatible, with the error messages being reasonably clear about the fallback mechanism.
Json strings, numbers and booleans are supported as-is, and the default section also works (sections are distinguished by their name being in
[brackets]
).Potentially a bit more documentation might be needed.