confy icon indicating copy to clipboard operation
confy copied to clipboard

Add a way to add comments and TOML sections to config files

Open sburris0 opened this issue 4 years ago • 5 comments

Comments can make config files more user-friendly by giving hints about possible values and where more info can be found. When config files get large, sections are useful to break it up so that things are easier to find.

Thanks for making this, confy made my life much much easier today.

sburris0 avatar Feb 15 '21 04:02 sburris0

So, as far as I see, this crate uses the default toml implementation for rust: The toml crate. The toml crate is toml compliant, thus you can simply use comments in your config files:

# this is a comment
foo = "bar"

Right? Or am I missing something?

matthiasbeyer avatar Feb 15 '21 07:02 matthiasbeyer

I am not an expert of the toml crate. But like @matthiasbeyer said, you can add comments manually, however I think that you cannot write a configuration with comments. I have never seen a way to manage comments in a config file programmatically.

Zykino avatar Feb 15 '21 18:02 Zykino

So, as far as I see, this crate uses the default toml implementation for rust: The toml crate. The toml crate is toml compliant, thus you can simply use comments in your config files:

# this is a comment
foo = "bar"

Right? Or am I missing something?

I should have been more specific. I want comments to be generated when the config file is created as most configuration files come pre-commented for clarity:


# make sxhkd reload its configuration files:
super + Escape
    pkill -USR1 -x sxhkd

#
# bspwm hotkeys
#

# quit/restart bspwm
super + alt + {q,r}
    bspc {quit,wm -r}

Cargo.toml has a note: # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

sburris0 avatar Feb 15 '21 18:02 sburris0

On 15-02-2021 10:42:49, Spencer Burris wrote:

Cargo.toml has a note: # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

I'd say that's because Cargo.toml is not generated from a struct, but simply copied from a template.

matthiasbeyer avatar Feb 15 '21 18:02 matthiasbeyer