Shemnei / punktf

⚡ A cross-platform multi-target dotfiles manager
https://shemnei.github.io/punktf/
Other
81 stars 6 forks source link

Handle file permissions #15

Open michidk opened 3 years ago

Shemnei commented 3 years ago

As punktf is platform independent we need to differentiate between unix and windows style permissions.

Draft

My idea would be to have an extra field per dotfile, something like mode, which holds the unix style of file permissions (a u32).

Windows

We would then have to think about a way to translate that to a windows style. Maybe if only the read/execute groups are set (e.g. 544) we could make the file readonly on windows. To translate that we would also have to decide which group matters (group, user, other). I personally would probably pick the user group.

Resources

michidk commented 3 years ago

I wouldn't use that feature if I would have to create a second file for each file that I wanna deploy on Linux. I want to keep it as simple as possible. So I just want a config option in the profile. The feature doesn't matter on windows. Not every feature needs to be available on all platforms, especially when other platforms don't have a certain problem we are trying to fix.

Shemnei commented 3 years ago

It would be an extra field on a dotfile configuration not file.

Example Profile:

variables:
  OS: "Windows"
dotfiles:
  - path: "scripts/test.sh"
    mode: 755

On a unix machine the mode would be set for the file. On windows we would set readonly to true as the user group has permissions 5 (r-x).

Another option could be to just ignore this field when running on non-unix machines.

A third option maybe to allow more than just the numeric values.

For example (as regex):

mode: ([0-7]{3}|readonly)
michidk commented 3 years ago

I would vote for ignoring. Not too sure of the implications of the flag. It's important to me, to be able to set the mode not only for one file, but for multiple files at once (one whole profile).