Skip to content

Commit

Permalink
try fix print_help to honor no_color
Browse files Browse the repository at this point in the history
  • Loading branch information
bckohan committed Jan 27, 2024
1 parent 7d30cbc commit ebc22fa
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions django_typer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -781,11 +781,13 @@ def print_help(self, *command_path: str):
with contextlib.redirect_stdout(self.django_command.stdout):
unset = False
if self.django_command.style == no_style():
unset = os.environ.get('NO_COLOR', None)
os.environ['NO_COLOR'] = '1'
unset = True
command_node.print_help()
if unset:
if unset is not False:
os.environ.pop('NO_COLOR')
if unset:
os.environ['NO_COLOR'] = unset

def parse_args(self, args=None, namespace=None):
try:
Expand Down
2 changes: 1 addition & 1 deletion django_typer/tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -812,7 +812,7 @@ def test_helps(self, app="test_app"):
]:
if app == "test_app" and cmds[-1] in ["strip", "setting", "print"]:
with self.assertRaises(ValueError):
cmd = get_command(cmds[0], stdout=buffer)
cmd = get_command(cmds[0], stdout=buffer, no_color=True)
cmd.print_help("./manage.py", *cmds)
continue

Expand Down

0 comments on commit ebc22fa

Please sign in to comment.