Introduce file-based user configuration #249
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR addresses #158.
klog now looks for a config file at
~/.klog/config.yml
, where users are able to specify some preferences. For now, that is:default_rounding
: the value for the--round
flag, unless specified, e.g. inklog start
orklog stop
.default_should_total
: the default for the--should-total
flag, unless specified, that is used whenever klog creates a new record, e.g. inklog create
, but also inklog track
orklog start
, as these might create new records on the fly.More configuration parameters may follow later, now that the groundwork is set up.
When the config file is absent, everything behaves as before, so it’s strictly optional right now.
What’s also new is that klog will respect the
$KLOG_FOLDER_LOCATION
or$XDG_CONFIG_HOME
environment variables, if set. In this case, and when users have bookmarks, then this will be a breaking change. The fix is for them to manually move over theirbookmarks.json
file to the new klog folder location. I’ll take note in the Changelog about this.The
klog config
command is hidden from the help output for now, but it can be invoked nevertheless on the nightly build (when compiling klog from themain
branch). I’ll do some more testing, refactoring, and enhancements in the next time, and plan to include this with the next release – probably within the next few weeks.