From fa481b4da9463ca0d0f7e72ba06f8c9330480c49 Mon Sep 17 00:00:00 2001 From: kolaente Date: Sat, 9 Feb 2019 14:12:22 +0100 Subject: [PATCH] [skip ci] Added description on how to add new config option --- .../new-config-options.md | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/docs/practical-instructions/new-config-options.md b/docs/practical-instructions/new-config-options.md index 0c7aead9c..1df3fed73 100644 --- a/docs/practical-instructions/new-config-options.md +++ b/docs/practical-instructions/new-config-options.md @@ -1,3 +1,21 @@ # Adding new config options -where, how to use them etc. \ No newline at end of file +Vikunja uses [viper](https://github.com/spf13/viper) to handle configuration options. +It handles parsing all different configuration sources. + +The configuration is done in sections. These are represented with a `.` in viper. +Take a look at `pkg/config/config.go` to understand how these are set. + +To add a new config option, you should add a default value to `pkg/config/config.go`. +Default values should always enable the feature to work somehow, or turn it off completely if it always needs +additional configuration. + +Make sure to add the new config option to [the config document](../setup/config.md) and the default config file +(`config.yml.sample` at the root of the repository) to make sure it is well documented. + +If you're using a computed value as a default, make sure to update the sample config file and debian +post-install scripts to reflect that. + +To get a configured option, use `viper.Get("config.option")`. +Take a look at [viper's documentation](https://github.com/spf13/viper#getting-values-from-viper) to learn of the +different ways available to get config options. \ No newline at end of file