Skip to content
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

Introduce file-based user configuration #249

Merged
merged 9 commits into from
Feb 13, 2023
Merged

Introduce file-based user configuration #249

merged 9 commits into from
Feb 13, 2023

Conversation

jotaen
Copy link
Owner

@jotaen jotaen commented Feb 13, 2023

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. in klog start or klog stop.
  • default_should_total: the default for the --should-total flag, unless specified, that is used whenever klog creates a new record, e.g. in klog create, but also in klog track or klog 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 their bookmarks.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 the main 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.

@jotaen jotaen merged commit dc2053c into main Feb 13, 2023
@jotaen jotaen deleted the config-file branch February 13, 2023 20:16
@jotaen jotaen mentioned this pull request Feb 13, 2023
@ulken
Copy link

ulken commented Feb 13, 2023

Awzum sauce! Nice choice of starter settings as well 😁

One minor nitpick: The name of the env var sticks a little. The suffix _FOLDER_LOCATION feels unfamiliar/unconventional. Any particular reason not to go with more established _HOME (JAVA_HOME, XDG_CONFIG_HOME) or PATH (MANPATH, GOPATH)?

@jotaen
Copy link
Owner Author

jotaen commented Feb 13, 2023

Good question. I realized that it’s probably a good idea to look into this whole config folder topic more properly anyway before the next release, so → #250.

jotaen added a commit that referenced this pull request Mar 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants