Skip to content

Conversation

@cjbassi
Copy link

@cjbassi cjbassi commented Jan 11, 2019

This change makes wpm load and store config files to ~/.config/wpm by default, specifically the wpm.csv and wpmrc files. It also removes the current functionality of loading config files from the home directory, but let me know if I should readd that functionality as a fallback if the ~/.config/wpm/* files don't exist since this would be a breaking change otherwise.

@cslarsen
Copy link
Owner

The PR itself is fair enough, but does indeed break a lot for existing, casual users (myself included). If I'd merge this, then it would not read my current settings or stats.

I think you need an upgrade strategy in the PR, where you copy the files over. Also, make sure .config exists. I am not too deep into the XDG specs, but if you can help me out understanding how this is useful (and provide an automatic switchover functionality) then I'd merge this PR.

@cjbassi
Copy link
Author

cjbassi commented Jan 28, 2019

Yah, breaking changes should definitely be avoided. I think the best solution would be to readd support for the currently used config file paths in this PR and default to that if the ~/.config/wpm/* files don't exist. So we're just creating a hierarchical lookup for the config file paths, which is a pretty standard cli app feature actually.

Also, the OSX standardization would need to be added to this PR, as mentioned in #42.

@cjbassi cjbassi changed the title Change default location for config files to ~/.config/wpm/ (Close #42) [WIP] Change default location for config files to platform defined config folder (Close #42) Jan 29, 2019
Copy link
Owner

@cslarsen cslarsen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the late reply. If you fix get_config_directory so that it works absolutely the same way if you already have your files in ~/, then I can pull the PR.

Also, is it really common to put non-config files in XDG_CONFIG_HOME as well (I'm thinking about the CSV file)?

self.filename = os.path.expanduser("~/.wpmrc")
config_directory = get_config_directory()
self.filename = os.path.join(config_directory, "wpmrc")
os.makedirs(config_directory, exist_ok=True)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like creating this directory.

I'd rather want get_config_directory to (1) check if you already have ~/.wpmrc and just use that if people already have it there. If not, check that XDG_CONFIG_HOME is set and points to an existing directory, then return that if so.

xdg_config_home = os.getenv("XDG_CONFIG_HOME")
if xdg_config_home == "":
xdg_config_home = os.path.join(os.getenv("HOME"), ".config")
return os.path.join(xdg_config_home, "wpm")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comments below.

help="Shows CPM instead of WPM in stats")

argp.add_argument("--stats-file", default="~/.wpm.csv", type=str,
argp.add_argument("--stats-file", default="~/.config/wpm/wpm.csv", type=str,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather get the default path here from get_config_directory

GTAGS
stats
.mypy_cache/
.vscode/
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't add these here. You can add your local gitignore under .git/info/exclude instead.

----------------------

wpm will save scores in a CSV file in `~/.wpm.csv`. This file can be loaded
wpm will save scores in a CSV file in `~/.config/wpm/wpm.csv`. This file can be loaded
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather just use wpm.csv since this will (according to what I propose) be in different directories, dependent on what system and setup you have. Then add a short section where you describe how we decide where the file goes (simple: first time user and you have XDG_HOME, it goes there, otherwise your home directory).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants