sdkman / sdkman-cli

The SDKMAN! Command Line Interface
https://sdkman.io
Apache License 2.0
5.99k stars 628 forks source link

Feature: stop mixing the default config with user config in a single file #941

Open felipecrs opened 3 years ago

felipecrs commented 3 years ago

Feature request

All started with https://github.com/sdkman/sdkman-cli/pull/928, which happened after I decided to include sdkman's config in my dotfiles repository: https://github.com/felipecrs/dotfiles/blob/c83fc79656129c35aa39501bab1c58f4a5bd683a/dot_sdkman/etc/config

So it turns out that sdkman expects some user configuration variables to be set, and treat them as the default settings. But it may not be a good idea to change the user's config file unattendedly during a self-update or on installation.

More insights comes from https://github.com/sdkman/sdkman-cli/pull/927#discussion_r664130904:

I'm 100% against assuming everyone will have this set in their config files. For example, I manage my dotfiles using another program, so I'm the one who makes changes to it. If later in the future sdkman introduces new config variables, I would miss it as my dotfiles manager would override it with my own wrote config again.

I think there are 2 different things that should not be mixed:

  1. Default settings
  2. User preferences (the ~/.sdkman/etc/config file)

And I don't think sdkman should make changes unattended(ly) to the user preferences, but only to the default settings. Just like Git (~/.gitconfig) or any other tool.

So my proposal is:

Have the ~/.sdkman/etc/config as the default configuration source. This file can be included in this repository, and it does not need to be primed during an installation or dynamically updated during a self-update. An update of SDKMAN will contain the file, just like the other files.

Inside of this file, all the possible configuration variables will be set with their default values (some of them can be removed from sdkman-init.sh thus, such as the curl related ones).

Then, an user can optionally set its own configuration options in another file. And by following XDG's recommendation, this file should be at ~/.config/sdkman/config/~/.config/sdkman/rc. Or ~/.sdkmanconfig/~/.sdkmanrc.

The sdkman-main should read the configuration this way:

# load default settings
source $SDKMAN_DIR/etc/config

# load user settings
source $XDG_CONFIG_HOME/sdkman/config

The latter instruction will override any variables set with the default settings.

untainsYD commented 9 months ago

I really do support this ISSUE!!!

sdavids commented 8 months ago

https://github.com/sdkman/sdkman-cli/pull/1069#issuecomment-1792936147