Skip to content

Commit

Permalink
Added quiet mode to not show output. (#103)
Browse files Browse the repository at this point in the history
  • Loading branch information
roykrikke authored Mar 24, 2021
1 parent cfb79d5 commit f2826b6
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
9 changes: 9 additions & 0 deletions phockup.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,14 @@ def main():
""",
)

parser.add_argument(
"-q",
"--quiet",
action="store_true",
help="""Run without output
""",
)

parser.add_argument(
"input_dir",
metavar="INPUTDIR",
Expand All @@ -167,6 +175,7 @@ def main():
timestamp=args.timestamp,
date_field=args.date_field,
dry_run=args.dry_run,
quiet=args.quiet,
)


Expand Down
3 changes: 3 additions & 0 deletions src/phockup.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ def __init__(self, input_dir, output_dir, **args):
self.timestamp = args.get('timestamp', False)
self.date_field = args.get('date_field', False)
self.dry_run = args.get('dry_run', False)
self.quiet = args.get('quiet', False)

printer.should_print(self.quiet)

self.check_directories()
self.walk_directory()

Expand Down
16 changes: 12 additions & 4 deletions src/printer.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,16 @@


class Printer(object):

def __init__(self):
self.quiet = False

def line(self, message, skip_end=False):
if skip_end:
print(message, end="", flush=True)
else:
print(message)
if not self.quiet:
if skip_end:
print(message, end="", flush=True)
else:
print(message)

def error(self, message):
self.line('')
Expand All @@ -18,3 +23,6 @@ def empty(self, times=1):
for i in range(times):
print('')
return self

def should_print(self, quiet):
self.quiet = quiet

0 comments on commit f2826b6

Please sign in to comment.