Skip to content

Commit

Permalink
fix: print leader with --color flag
Browse files Browse the repository at this point in the history
  • Loading branch information
phette23 committed Jan 29, 2025
1 parent a1080a5 commit 64dd893
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions marcgrep/color.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,12 @@ def color_field(field: Field, invert: bool) -> None:


def color_record(record: Record, invert: bool) -> None:
# create COLORS global if we have not already
if not globals().get("COLOR"):
_setup_colors(invert)

cprint("LDR", COLORS["TAG"], end=" ")
cprint(record.leader, COLORS["DATA"])
for field in record:
color_field(field, invert)
click.echo()
6 changes: 6 additions & 0 deletions test/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,3 +180,9 @@ def test_glob(self):
)
assert result.exit_code == 0
assert len(result.output.splitlines()) == 1

def test_color_leader(self):
runner = CliRunner()
result = runner.invoke(main, ["--color", ONE_RECORD])
assert result.exit_code == 0
assert result.output.splitlines()[0] == "LDR 03292namaa2200793uu 4500"

0 comments on commit 64dd893

Please sign in to comment.