Skip to content

Commit

Permalink
Merge pull request #7 from The-Compiler/force-colors
Browse files Browse the repository at this point in the history
Add a --force-colors switch
  • Loading branch information
kracekumar authored Mar 23, 2021
2 parents 7e69919 + 8783d21 commit b02801c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
3 changes: 2 additions & 1 deletion jut/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ class Config(BaseModel):
tail: int
single_page: bool
full_display: bool
force_colors: bool

@validator("input_file")
def validate_input_file(cls, val):
Expand Down Expand Up @@ -147,7 +148,7 @@ def __init__(self, config: Config):
custom_theme = Theme(
{"info": "dim cyan", "warning": "magenta", "danger": "bold red"}
)
self.console = Console(theme=custom_theme)
self.console = Console(theme=custom_theme, force_terminal=config.force_colors)

def parse_notebook(self):
"""Parse the notebook content."""
Expand Down
10 changes: 9 additions & 1 deletion jut/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,14 @@ def download_url(url):
is_flag=True,
help="Should all the contents in the file displayed?",
)
def display(url, input_file, head, tail, single_page, full_display):
@click.option(
"--force-colors",
type=bool,
default=False,
is_flag=True,
help="Force colored output even if stdout is not a terminal",
)
def display(url, input_file, head, tail, single_page, full_display, force_colors):
destination_file = None
if url:
destination_file = download_url(url)
Expand All @@ -77,6 +84,7 @@ def display(url, input_file, head, tail, single_page, full_display):
tail=tail,
single_page=single_page,
full_display=full_display,
force_colors=force_colors,
)
render = Render(config)
render.render()
Expand Down

0 comments on commit b02801c

Please sign in to comment.