rschroll / rmfuse

FUSE access to the reMarkable Cloud
MIT License
95 stars 8 forks source link

default args configfile #14

Closed f3fora closed 3 years ago

f3fora commented 3 years ago

Default mode option is hardcoded in rmfuse and rmrl.render ones in rmcl or rmrl.

I think it would be a great idea to have a config file for defaults. If it would be managed by configparser, it should look like:

[rmfuse]
mountpoint = /home/user/remarkable
mode = annot

[rmrl]
alpha = 0.3
no-expand = no
only-annotated = no

However, rmfuse has no explicit dependence on rmrl and it is impossible to pass args to rmrl.render So, do you prefer to manage render defaults directly with rmrl?

Moreover, rmfuse and rmcl have different version dependence on rmrl, and this can be a problem.

rschroll commented 3 years ago

I was already working on this, and we now have a config file for rendering options. I've gone back and forth on whether the mount options should go into the config file as well. What's blocking me at the moment is that both the argparser and configparser are set up to provide defaults when an option is not specified. So there's no way at present to detect that an option wasn't given with one, and therefore the other one should be used. It's obviously possible to do this, but all the things I've thought of feel ugly.

I'll leave this open, and I welcome thoughts about implementation. But the rendering configs are the big ones, I think, since there's no other way to specify them, so we may wait on the rest of this.

f3fora commented 3 years ago

You can set the default values in configparser and suppress the default in argparse

parser = argparse.ArgumentParser(argument_default=argparse.SUPPRESS)

Then use the values you get to update the dictionary of configparser ones. In such a way, the priority of default is:

  1. args
  2. config
  3. hardcoded

Maybe the code can be more organized between files. Having args/config parser in fuse.py and config.py does not have any sense.