roamer icon indicating copy to clipboard operation
roamer copied to clipboard

.roamerrc file instead of environment variables

Open abaldwin88 opened this issue 7 years ago • 8 comments

abaldwin88 avatar Aug 06 '17 14:08 abaldwin88

Looks like the values to load from .roamerrc are just: ROAMER_DATA_PATH and ROAMER_EDITOR. They’re used in three places: roamer/constant.py, roamer/file_edit.py, and tests/test_integration.py. I’d probably move the editor selection into the constants file too. Thoughts?

skiningham avatar Aug 09 '17 14:08 skiningham

Correct those are the two values that need to be moved. Yes the editor selection belongs in the constants file. Good catch!

abaldwin88 avatar Aug 09 '17 15:08 abaldwin88

Imho you should consider xdg compliance (https://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html). Not sure how hard that is, though :)

KillTheMule avatar Aug 30 '17 10:08 KillTheMule

Here's a general outline of the direction I'd like to take. I want this to be a collaboration so please comment if you have a differing opinion.

We should follow the XDG Specification. https://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html

We can add this package as a dependency... https://github.com/srstevenson/xdg

If it's helpful we can loosely base this the way Ranger does it... https://github.com/ranger/ranger/blob/d861ba27b25a32aacb845eb33b6c9ce95cb33356/ranger/ext/rifle.py#L383-L407

For the actual layout of the config file my preference would be to follow INI file structure as that seems to be the most widely adopted. I do think forcing users to include a [section] is crufty for a tool like roamer.

.roamerrc example...

ROAMER_EDITOR=emacs
# comment line
OPTIONS=--skip-approval,--future-other-flag

We can use configparser library to get most of logic but we'll need to work around the expectation of sections.

https://stackoverflow.com/questions/2885190/using-pythons-configparser-to-read-a-file-without-section-name

abaldwin88 avatar Nov 28 '17 14:11 abaldwin88

Yeah, following XDG Specification is great, but I think that use additional package is overkill for the ~10 lines.

I see two options if config file does not exists at XDG dirs:

  1. create it there
  2. check somewhere else, for example here: ~/.config/roamer

As about .rc file itself -- at least for now It would be enough to have plain text file, and parse it without libs.

alex-bender avatar Nov 28 '17 15:11 alex-bender

@abaldwin88 so what about Windows ~~~and what to do if there is no $XDG_CONFIG_HOME var~~~?

Update

$XDG_CONFIG_HOME defines the base directory relative to which user specific configuration files should be stored. If $XDG_CONFIG_HOME is either not set or empty, a default equal to $HOME/.config should be used.

alex-bender avatar Nov 29 '17 12:11 alex-bender

Yep the spec has a default location to use when the var isn't set.

Windows is only supported in roamer using the ubuntu subsystem. So using $HOME/.config should work fine. I have a windows box I'll test it on before merging.

Add dependencies at your discretion. If you can write something simple that covers our bases then let's add it directly.

abaldwin88 avatar Nov 29 '17 16:11 abaldwin88

@abaldwin88 Just want to say that I've got pretty busy days and that's why I didn't implement it yet. But I'm looking forward for doing it.

alex-bender avatar Dec 09 '17 16:12 alex-bender