Hello, I noticed the lego directory containing accounts and certificates get saved at the current working directory.
This might introduce inconsistency depending on the location you run it.
Saving the directory under $HOME like many other programs might be favorable.
Regards
hello,
I understand your point, it's a breaking change so we will not introduce it quickly.
Could we change the mechanism for determining the path location to prefer $PWD/.lego
, and if that doesn't exist fallback to $HOME/.lego
(or actually $XDG_CONFIG_HOME/lego
on Linux)? This way existing installations would continue to work. Of course, --path
still takes precedence.
In full, the code would look like this:
def default_path
# $PWD/.lego
if (local = Pathname.new(__dir__).join(".lego")).exist?
return local
end
# Linux: ${XDG_CONFIG_HOME:-$HOME/config}/lego
home = Pathname.new ENV.fetch("HOME")
if Etc.uname[:sysname] == "Linux"
xdg = ENV.fetch("XDG_CONFIG_HOME", home.join(".config")))
return Pathname.new(xdg).join("lego")
end
# Windows: %AppData%\Roaming\lego
if Etc.uname[:sysname] == "Windows"
return Pathname.new(ENV.fetch("APPDATA")).join("Roaming/lego")
end
# other: $HOME/.lego
home.join(".lego")
end
(This is pseudo-code in Ruby, the actual implementation could make use of appropriate build tags and e.g. implement the Linux-specific code in config_dir_linux.go
to get rid of runtime conditionals.)
Currently the ./.lego
folder is created if this folder don't exist, so a fallback it's not possible without breaking the current behavior.
Why is that?
lego
on existing installations would continue to use ./.lego
.~/.config/lego
.--path
.Am I missing a use case?
Most helpful comment
Why is that?
lego
on existing installations would continue to use./.lego
.~/.config/lego
.--path
.Am I missing a use case?