mirror of
https://github.com/samsonjs/vdirsyncer.git
synced 2026-04-27 14:57:41 +00:00
Add a --config option.
This commit is contained in:
parent
69b88dd0c0
commit
10cc4b1a16
3 changed files with 9 additions and 5 deletions
|
|
@ -14,6 +14,8 @@ Version 0.10.0
|
||||||
|
|
||||||
- New storage types :storage:`google_calendar` and :storage:`google_contacts`
|
- New storage types :storage:`google_calendar` and :storage:`google_contacts`
|
||||||
have been added.
|
have been added.
|
||||||
|
- New global command line option `--config`, to specify an alternative config
|
||||||
|
file. See :gh:`409`.
|
||||||
|
|
||||||
Version 0.9.3
|
Version 0.9.3
|
||||||
=============
|
=============
|
||||||
|
|
|
||||||
|
|
@ -50,9 +50,10 @@ def _check_python2():
|
||||||
@click_log.init('vdirsyncer')
|
@click_log.init('vdirsyncer')
|
||||||
@click_log.simple_verbosity_option()
|
@click_log.simple_verbosity_option()
|
||||||
@click.version_option(version=__version__)
|
@click.version_option(version=__version__)
|
||||||
|
@click.option('--config', '-c', metavar='FILE', help='Config file to use.')
|
||||||
@pass_context
|
@pass_context
|
||||||
@catch_errors
|
@catch_errors
|
||||||
def app(ctx):
|
def app(ctx, config):
|
||||||
'''
|
'''
|
||||||
vdirsyncer -- synchronize calendars and contacts
|
vdirsyncer -- synchronize calendars and contacts
|
||||||
'''
|
'''
|
||||||
|
|
@ -60,7 +61,7 @@ def app(ctx):
|
||||||
from .config import load_config
|
from .config import load_config
|
||||||
|
|
||||||
if not ctx.config:
|
if not ctx.config:
|
||||||
ctx.config = load_config()
|
ctx.config = load_config(config)
|
||||||
|
|
||||||
main = app
|
main = app
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -79,9 +79,10 @@ def _validate_pair_section(pair_config):
|
||||||
raise ValueError('Duplicate values in collections parameter.')
|
raise ValueError('Duplicate values in collections parameter.')
|
||||||
|
|
||||||
|
|
||||||
def load_config():
|
def load_config(fname=None):
|
||||||
fname = os.environ.get('VDIRSYNCER_CONFIG', None)
|
if fname is None:
|
||||||
if not fname:
|
fname = os.environ.get('VDIRSYNCER_CONFIG', None)
|
||||||
|
if fname is None:
|
||||||
fname = expand_path('~/.vdirsyncer/config')
|
fname = expand_path('~/.vdirsyncer/config')
|
||||||
if not os.path.exists(fname):
|
if not os.path.exists(fname):
|
||||||
xdg_config_dir = os.environ.get('XDG_CONFIG_HOME',
|
xdg_config_dir = os.environ.get('XDG_CONFIG_HOME',
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue