Skip to content

Commit

Permalink
fix: use click.echo instead of print
Browse files Browse the repository at this point in the history
  • Loading branch information
phette23 committed Nov 2, 2024
1 parent e721c8a commit a1080a5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
6 changes: 3 additions & 3 deletions marcgrep/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,17 +71,17 @@ def main(
if color:
color_field(f, invert)
else:
print(f)
click.echo(f)
else:
if color:
color_record(record, invert)
else:
print(record)
click.echo(record)
if limit and counter >= limit:
break

if count:
print(f"{file.name}: {matched_records}")
click.echo(f"{file.name}: {matched_records}")

# non-zero exit if no records match
return exit(0 if any_matches else 1)
Expand Down
5 changes: 3 additions & 2 deletions marcgrep/color.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from os import environ
from typing import get_args

import click
from pymarc import Field, Record
from termcolor import cprint
from termcolor._types import Color
Expand Down Expand Up @@ -72,10 +73,10 @@ def color_field(field: Field, invert: bool) -> None:
for subfield in field.subfields:
cprint(f"{DELIMITER}{subfield.code}", COLORS["SUBFIELD"], end="")
cprint(f"{subfield.value}", COLORS["DATA"], end="")
print()
click.echo()


def color_record(record: Record, invert: bool) -> None:
for field in record:
color_field(field, invert)
print()
click.echo()

0 comments on commit a1080a5

Please sign in to comment.