Created
February 6, 2022 15:27
-
-
Save MartinThoma/c5e362e776a80e71db35762be6461e2f to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import typer | |
from pathlib import Path | |
from rich.console import Console | |
from rich.syntax import Syntax | |
def app(filepath: Path = typer.Option(..., exists=True)): | |
"""Print a python file.""" | |
with open(filepath, "r") as f: | |
code = f.read() | |
syntax = Syntax(code, "python", theme="solarized-dark", line_numbers=True) | |
console = Console() | |
console.print(syntax) | |
if __name__ == "__main__": | |
typer.run(app) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment