gnebbia / kb

A minimalist command line knowledge base manager
GNU General Public License v3.0
3.17k stars 104 forks source link

XDG Compliance #87

Closed hyperupcall closed 3 years ago

hyperupcall commented 3 years ago

Expected Behavior

Puts kb data in "${XDG_DATA_HOME:-$HOME/.local/share}/kb"

It would be great to follow the XDG Base Directory Specification and place application data files in $XDG_DATA_HOME/kb, if it exists, and fall back to $HOME/.local/share/kb if that environment variable does not exist. It was mentioned offhand in this thread, but I would like to make an issue to address this :)

Actual Behavior

kb data put in ~/.kb.

Steps to Reproduce the Problem

Execute a kb command

Specifications

xscode-auto-reply[bot] commented 3 years ago

Thanks for opening a new issue. The team has been notified and will review it as soon as possible. For urgent issues and priority support, visit https://xscode.com/gnebbia/kb

gnebbia commented 3 years ago

Dear Sir, XDG compliance is surely a priority, hence with the next release the default directory will change its position. Let's keep this open until it is fixed.

gnebbia commented 3 years ago

Dear Sir, XDG compliance has been implemented. Of course it will break some sort of compatibility with previous versions.

A fix can be users moving $HOME/.kb into $HOME/.local/share/kb or into the XDG_DATA_HOME directory.

At the moment this is of course only implemented within the git version but as soon as 0.1.7 will come out this will be the default.

hyperupcall commented 3 years ago

Thank you very much! I am excited to see this change in the new release :)

hyperupcall commented 3 years ago

@gnebbia I checked some of the changes, and I just wanted to be sure of something :P

Could it be that the following code matches your description a bit more:

BASE_PATH = Path(os.environ.get("XDG_DATA_HOME",Path(Path.home(),".local","share")),"kb")

It looks like that with the current changes, if XDG_DATA_HOME is defined, then PATH_KB would be set to $XDG_DATA_HOME and PATH_KB_GIT would be set to $XDG_DATA_HOME/.git, rather than $XDG_DATA_HOME/kb and $XDG_DATA_HOME/kb/.git, respectively

gnebbia commented 3 years ago

Yes you are right, my bad.

This the latest commit should fix this for good. Thanks to your suggestion and testing. Really, thanks a lot!