SuperCuber / dotter

A dotfile manager and templater written in rust 🦀
The Unlicense
882 stars 46 forks source link

[FEATURE(S)] Conditional includes and multiple caches #104

Closed HiImJulien closed 2 years ago

HiImJulien commented 2 years ago

Hey there! I have four platforms that I regularly work on:

The first two platforms use the "local.toml" approach as intended. The latter two, however, cause an issue.

Is your feature request related to a problem? Please describe. I have cloned my dotfiles into C:/.../Documents/Repositories (on Windows). Inside WSL I have a symlink ~/Repositories which points to C:/.../Documents/Repositories. For linux I use my default "global.toml" whereas for windows I have a "windows.toml".

Running dotter twice in the same directory but once from Windows and once from WSL leaves me with an error message stating that the cache is corrupt, since it cannot access windows paths from within wsl and vice versa.

The only workaround I have found so far was to checkout my dotfiles repo twice, where one copy belongs to each platform. This is really annoying, when I am tweaking my configs e.g. for neoVIm and need to test whether everything works as intended on linux as well as windows.

Describe the solution you'd like I'd love to

  1. Specify my includes using a conditions, since I have only one "local.toml" used by two platforms/runtimes.
  2. Have a separate cache sections for each platform that dotter detects on the same PC.

For example the cache could be reworked to store links in a format like that:

[templates.unix]
"nvim\\init.lua" = "C:\\WindowsPathSaysWhat\\init.lua"

[templates.windows]
"nvim\\init.lua" = "/home/Whaaat/.config/nvim/init.lua

Describe alternatives you've considered

SuperCuber commented 2 years ago

For the cache issues, you could run dotter with the flags --cache-directory and --cache-file with a separate one for each install, and have an alias that runs it with the correct ones depending on the platform - implementing it inside of dotter will probably introduce a bunch of bugs and I think it's a bit out of scope.

For conditionally including files - this is already a feature, check out conditional files

HiImJulien commented 2 years ago

Neat, the --cache-file solves one of my problems.

For conditionally including files - this is already a feature, check out conditional files

I already looked into this but this is not an option, since there are too many single-file configs. My issue is not about conditionally linking a single file. It's about conditionally including a windows.toml into my local.toml.

Is there are a flag with which I can specify which local.toml to use as well?

SuperCuber commented 2 years ago

Is there are a flag with which I can specify which local.toml to use as well?

If only there was a way to list all the flags :P (im talking about --help)

HiImJulien commented 2 years ago

Whoops. Thanks <3