eyeonus / Trade-Dangerous

Mozilla Public License 2.0
98 stars 31 forks source link

use user profile directories for data instead of CWD #86

Closed draeath closed 3 years ago

draeath commented 3 years ago

Hello,

By common convention, trade dangerous should be using user-relative profile directories instead of looking for the data directory in the CWD.

For example, on linux or OSX either ${HOME}/.tradedangerous, or ${HOME}/.config/tradedangerous or ${HOME}/.local/share/tradedangerous and on windows %appdata%\tradedangerous

In the examples given, ${HOME} can be retrieved via os.getenv('HOME') and %appdata% via os.getenv('APPDATA'). You can detect the platform (to guide which of those to use) via platform.system() or os.name()

This prevents pollution of home directories and inconsistent results if the CWD is not consistent when running the tool.

eyeonus commented 3 years ago

This is accomplished using the environment variables $TD_DATA, $TD_TMP, $TD_EDDB, which override the default location of the ./data, ./tmp, and ./data/eddb folders respectively with the value set in the envvar, or the command line arguments '--cwd ...', '--db ...', which override the 'top-level' directory and the 'TradeDangerous.db' location with the passed value.

Of the options available, 'trade --cwd ~/.tradedangerous ...' would be the simplest way to accomplish what you want.

draeath commented 3 years ago

Ah. Thanks!