-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature/24 support a quiet flag to silence output (#86)
* Add convenience functions for console printing * Implement quiet flag Enable "PT" Bump ruff * Pass tests, fix bug with removing bitbucket ci
- Loading branch information
1 parent
49dcb5e
commit cbba529
Showing
18 changed files
with
276 additions
and
153 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,29 @@ | ||
import typer | ||
from collections.abc import Generator | ||
from contextlib import contextmanager | ||
|
||
from pydantic import BaseModel | ||
from rich.console import Console | ||
|
||
console = Console() | ||
typer_console = Console() | ||
|
||
|
||
class UsethisConsole(BaseModel): | ||
quiet: bool | ||
|
||
def tick_print(self, msg: str) -> None: | ||
if not self.quiet: | ||
typer_console.print(f"✔ {msg}", style="green") | ||
|
||
def box_print(self, msg: str) -> None: | ||
if not self.quiet: | ||
typer_console.print(f"☐ {msg}", style="blue") | ||
|
||
@contextmanager | ||
def set(self, *, quiet: bool) -> Generator[None, None, None]: | ||
"""Temporarily set the console to quiet mode.""" | ||
self.quiet = quiet | ||
yield | ||
self.quiet = False | ||
|
||
|
||
offline_opt = typer.Option(False, "--offline", help="Disable network access") | ||
console = UsethisConsole(quiet=False) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
import typer | ||
|
||
offline_opt = typer.Option(False, "--offline", help="Disable network access") | ||
quiet_opt = typer.Option(False, "--quiet", help="Suppress output") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.