mirror of
https://github.com/samsonjs/vdirsyncer.git
synced 2026-04-27 14:57:41 +00:00
Better verbosity CLI option, no config value
This commit is contained in:
parent
542718d311
commit
61cc5bbf75
2 changed files with 23 additions and 11 deletions
|
|
@ -4,7 +4,6 @@
|
||||||
[general]
|
[general]
|
||||||
# A folder where vdirsyncer can store some metadata about each pair.
|
# A folder where vdirsyncer can store some metadata about each pair.
|
||||||
status_path = ~/.vdirsyncer/status/
|
status_path = ~/.vdirsyncer/status/
|
||||||
#verbose = False # setting this to true will show e.g. HTTP traffic
|
|
||||||
|
|
||||||
# CONTACTS
|
# CONTACTS
|
||||||
[pair bob_contacts]
|
[pair bob_contacts]
|
||||||
|
|
|
||||||
|
|
@ -137,14 +137,32 @@ def _main(env, file_cfg):
|
||||||
# https://github.com/DasIch/argvard/issues/2
|
# https://github.com/DasIch/argvard/issues/2
|
||||||
app.options['--help'].function(context)
|
app.options['--help'].function(context)
|
||||||
|
|
||||||
@app.option('--verbose|-v')
|
@app.option('--verbosity verbosity')
|
||||||
def verbose_option(context=None):
|
def verbose_option(context, verbosity):
|
||||||
'''Print more information.'''
|
'''
|
||||||
log.set_level(log.logging.DEBUG)
|
Basically Python logging levels.
|
||||||
|
|
||||||
|
CRITICAL: Config errors, at most.
|
||||||
|
|
||||||
|
ERROR: Normal errors, at most.
|
||||||
|
|
||||||
|
WARNING: Problems of which vdirsyncer thinks that it can handle them
|
||||||
|
itself, but which might crash other clients.
|
||||||
|
|
||||||
|
INFO: Normal output.
|
||||||
|
|
||||||
|
DEBUG: Show e.g. HTTP traffic. Not supposed to be readable by the
|
||||||
|
normal user.
|
||||||
|
|
||||||
|
'''
|
||||||
|
x = getattr(log.logging, verbosity, None)
|
||||||
|
if x is None:
|
||||||
|
raise ValueError(u'Invalid verbosity value: {}'.format(verbosity))
|
||||||
|
log.set_level(x)
|
||||||
|
|
||||||
@app.option('--quiet|-q')
|
@app.option('--quiet|-q')
|
||||||
def quiet_option(context=None):
|
def quiet_option(context=None):
|
||||||
'''Inverse of --verbose.'''
|
'''Print less information than normal.'''
|
||||||
log.set_level(log.logging.WARNING)
|
log.set_level(log.logging.WARNING)
|
||||||
|
|
||||||
sync_command = argvard.Command()
|
sync_command = argvard.Command()
|
||||||
|
|
@ -190,9 +208,4 @@ def _main(env, file_cfg):
|
||||||
action()
|
action()
|
||||||
|
|
||||||
app.register_command('sync', sync_command)
|
app.register_command('sync', sync_command)
|
||||||
|
|
||||||
if general.get('verbose', False):
|
|
||||||
verbose_option()
|
|
||||||
else:
|
|
||||||
quiet_option()
|
|
||||||
app()
|
app()
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue