Add a global --silent flag to silence output

issue #46
This commit is contained in:
Ivan Habunek 2018-06-15 09:02:19 +02:00
parent 72f88831ad
commit 92435d630c
No known key found for this signature in database
GPG Key ID: CDBD63C43A30BB95
2 changed files with 11 additions and 4 deletions

View File

@ -30,6 +30,11 @@ common_args = [
"action": 'store_true',
"default": False,
}),
(["--quiet"], {
"help": "don't write to stdout on success",
"action": 'store_true',
"default": False,
}),
(["--debug"], {
"help": "show debug log in console",
"action": 'store_true',

View File

@ -47,11 +47,13 @@ def strip_tags(text):
USE_ANSI_COLOR = "--no-color" not in sys.argv
QUIET = "--quiet" in sys.argv
def print_out(*args, **kwargs):
args = [colorize(a) if USE_ANSI_COLOR else strip_tags(a) for a in args]
print(*args, **kwargs)
if not QUIET:
args = [colorize(a) if USE_ANSI_COLOR else strip_tags(a) for a in args]
print(*args, **kwargs)
def print_err(*args, **kwargs):
@ -73,8 +75,8 @@ def print_instance(instance):
lines = [line.strip() for line in format_content(description) if line.strip()]
for line in lines:
for l in wrap(line.strip()):
print(l)
print()
print_out(l)
print_out()
def print_account(account):