insanum / gcalcli

Google Calendar Command Line Interface
MIT License
3.31k stars 311 forks source link

configFolder option is confusing wrt filenames #546

Closed strogiyotec closed 3 weeks ago

strogiyotec commented 4 years ago

According to documentation

gcalcli is able to store all its necessary information in a specific folder (use the --configFolder option.) Each folder will contain 2 files: oauth and cache

By default gcalcli creates oauth and cache in my home directory. I moved them into .config folder and want to specify new location using this command

gcalcli --configFolder ~/.config/gcalcli/ agenda

~/.config/gcalcli/ stores two files : .gcalcli_cache .gcalcli_oauth However I got this output

UserWarning: Cannot access ~/.gcalcli_oauth: No such file or directory
  warnings.warn(_MISSING_FILE_MESSAGE.format(filename))

Your browser has been opened to visit:

Which means that gcalcli ignored --configFolder location and tried to find oauth file inside home directory. How can I specify custom config folder ? Thank you (version gcalcli v4.3.0)

jcrowgey commented 4 years ago

Repro'd. Thanks for the report.

jcrowgey commented 4 years ago

Actually, looking closer, I believe that the issue is that when the files are in your home dir, they're named .gcalcli_oauth and .galcli_cache. The leading . hides them from normal dir listings and the gcalcli_ prefix namespaces them since they're in a generic location. However, when these files live in a specified folder, they no longer need the leading dot nor the prefix, they're simply called oauth and cache.

I don't think this is a software bug, since the usual workflow would be to let gcalcli create these files for you.

dbarnett commented 3 weeks ago

FYI I'm probably going to remove the configFolder option and replace it with better defaults using https://pypi.org/project/xdgappdirs/. These aren't even configs, they're data files, and users shouldn't really need to know or care what path they live at[^1] as long as they're not cluttering up important paths.

[^1]: Caveat: Users DO sometimes need to manually delete these files when gcalcli gets silly, so I still think it'd be useful to have certain commands spit out their paths and maybe explicit commands for deleting/manipulating them, even if it's not directly configurable.

dbarnett commented 3 weeks ago

Alright, I've cleaned up a lot of the mechanics for how these files work in #741. gcalcli will no longer create files in your homedir with alternate names, and will generally discover and move/rename such files to more suitable paths when it finds them, so you won't tend to have to guess and check how it works like this. Also I made the help text spit out some more self-explanatory diagnostics about config paths.

FWIW I considered but decided against 2 other related improvements that seemed like more trouble than they were worth:

  1. Also detect files named .gcalcli_FOO under config paths and rename them to FOO
  2. Warn about any other unrecognized filenames under config dir, in case they might be typos

Could revisit those ideas if people are still having problems.