mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-07-24 09:54:31 +02:00
--silent option for sqlite-utils insert-files, closes #301
This commit is contained in:
parent
d83b256813
commit
60dea99ef7
3 changed files with 31 additions and 7 deletions
|
|
@ -260,14 +260,21 @@ class ValueTracker:
|
|||
|
||||
|
||||
class NullProgressBar:
|
||||
def __init__(self, *args):
|
||||
self.args = args
|
||||
|
||||
def __iter__(self):
|
||||
yield from self.args[0]
|
||||
|
||||
def update(self, value):
|
||||
pass
|
||||
|
||||
|
||||
@contextlib.contextmanager
|
||||
def progressbar(silent=False, **kwargs):
|
||||
def progressbar(*args, **kwargs):
|
||||
silent = kwargs.pop("silent")
|
||||
if silent:
|
||||
yield NullProgressBar()
|
||||
yield NullProgressBar(*args)
|
||||
else:
|
||||
with click.progressbar(**kwargs) as bar:
|
||||
with click.progressbar(*args, **kwargs) as bar:
|
||||
yield bar
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue