Skip to content

Instantly share code, notes, and snippets.

@MartinThoma
Created February 6, 2022 15:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MartinThoma/c5e362e776a80e71db35762be6461e2f to your computer and use it in GitHub Desktop.
Save MartinThoma/c5e362e776a80e71db35762be6461e2f to your computer and use it in GitHub Desktop.
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