Skip to content

Commit

Permalink
Add an output pager.
Browse files Browse the repository at this point in the history
Fixes #50.
Requires pallets/click#1572.
  • Loading branch information
craigds committed Jun 5, 2020
1 parent 09287b2 commit df3ac87
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion sno/diff_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def diff_output_text(*, output_path, **kwargs):

def _out(dataset, diff):
with resolve_output_path(output_path) as fp:
pecho = {'file': fp, 'color': getattr(fp, 'color', fp.isatty())}
pecho = {'file': fp, 'color': True}
path = dataset.path
pk_field = dataset.primary_key
prefix = f"{path}:"
Expand Down
4 changes: 2 additions & 2 deletions sno/output_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def dump_json_output(output, output_path, json_style="pretty"):
"""

with resolve_output_path(output_path) as fp:
if json_style == 'pretty' and getattr(fp, 'color', fp.isatty()):
if json_style == 'pretty':
# Add syntax highlighting
from pygments import highlight
from pygments.lexers import JsonLexer
Expand Down Expand Up @@ -62,7 +62,7 @@ def resolve_output_path(output_path, allow_pager=True):
)

with _push_environment('PAGER', pager_cmd):
with click.get_pager_file(color=True) as pager:
with click.get_pager_file() as pager:
yield pager
else:
yield sys.stdout
Expand Down
2 changes: 1 addition & 1 deletion sno/show.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def patch_output_text(*, target, output_path, **kwargs):
"""
commit = target.head_commit
with resolve_output_path(output_path) as fp:
pecho = {'file': fp, 'color': getattr(fp, 'color', fp.isatty())}
pecho = {'file': fp, 'color': True}
with diff.diff_output_text(output_path=fp, **kwargs) as diff_writer:
author = commit.author
author_time_utc = datetime.fromtimestamp(author.time, timezone.utc)
Expand Down

0 comments on commit df3ac87

Please sign in to comment.