Credentials storage does not respect the XDG specification #108
Labels
complexity::low
Issues or ideas with a low implementation cost
component::cli
Everything related to the buffrs cli
type::refactoring
Changing the inner-workings of buffrs
Currently, the credentials are stored in a hard-coded path determined by the
$BUFFRS_HOME
variable, or in~/.buffrs/credentials.toml
, see this code. While this is initially a sensible approach, there are some improvements that could be made.Issues
Depending on the operating system that you are using, you may not want to store things in your home directory. Some operating systems do not understand the concept of dotfiles (files or folders, which are hidden by default due to a leading dot in their name). Some people may prefer to not clobber their home directories with configuration, but rather store it somewhere else.
In general, it is warmly recommended to adhere to a standard when it comes to storing configuration rather than "clobbering" user's home directories with it. See also
Standard
For this reason, the XDG group has a specification called the XDG Base Directory Specification which sets standards that applications should respect. One of these standards defines where configuration should be stored. The default location as per this standard would be
~/.config/buffrs/credentials.toml
, but the spec also defines environment variables that can be set to change this.Similarly, Windows has the KNOWNFOLDERID API and macOS the Standard Directories.
Solution
We can use the dirs crate to consume these standards. Another crate offered by the same team is directories, which should make it even easier for us.
Notes
Note that many applications still do not respect the XDG standard, including my beloved editor
vim
. It is not the end of the world if we do not adhere to them. But I do believe that it is a good standard and that there are few reasons not to stick to it. Ideally, we can stick to it in a backwards-compatible way, such that the application would prefer configuration created in the XDG-compatible paths, but would also search the current locations.See Also
$HOME
$HOME
, not so sweet$HOME
The text was updated successfully, but these errors were encountered: