Skip to content

Commit 64dd893

Browse files
committed
fix: print leader with --color flag
1 parent a1080a5 commit 64dd893

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

marcgrep/color.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,12 @@ def color_field(field: Field, invert: bool) -> None:
7777

7878

7979
def color_record(record: Record, invert: bool) -> None:
80+
# create COLORS global if we have not already
81+
if not globals().get("COLOR"):
82+
_setup_colors(invert)
83+
84+
cprint("LDR", COLORS["TAG"], end=" ")
85+
cprint(record.leader, COLORS["DATA"])
8086
for field in record:
8187
color_field(field, invert)
8288
click.echo()

test/test_cli.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,3 +180,9 @@ def test_glob(self):
180180
)
181181
assert result.exit_code == 0
182182
assert len(result.output.splitlines()) == 1
183+
184+
def test_color_leader(self):
185+
runner = CliRunner()
186+
result = runner.invoke(main, ["--color", ONE_RECORD])
187+
assert result.exit_code == 0
188+
assert result.output.splitlines()[0] == "LDR 03292namaa2200793uu 4500"

0 commit comments

Comments
 (0)