time to get RICH
This commit is contained in:
parent
dda6c9f1b7
commit
d44340ab9d
48
poetry.lock
generated
48
poetry.lock
generated
@ -139,6 +139,17 @@ category = "main"
|
|||||||
optional = false
|
optional = false
|
||||||
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*"
|
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "commonmark"
|
||||||
|
version = "0.9.1"
|
||||||
|
description = "Python parser for the CommonMark Markdown spec"
|
||||||
|
category = "main"
|
||||||
|
optional = false
|
||||||
|
python-versions = "*"
|
||||||
|
|
||||||
|
[package.extras]
|
||||||
|
test = ["hypothesis (==3.55.3)", "flake8 (==3.7.8)"]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "crashtest"
|
name = "crashtest"
|
||||||
version = "0.3.1"
|
version = "0.3.1"
|
||||||
@ -422,6 +433,14 @@ category = "dev"
|
|||||||
optional = false
|
optional = false
|
||||||
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*"
|
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "pygments"
|
||||||
|
version = "2.12.0"
|
||||||
|
description = "Pygments is a syntax highlighting package written in Python."
|
||||||
|
category = "main"
|
||||||
|
optional = false
|
||||||
|
python-versions = ">=3.6"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "pylev"
|
name = "pylev"
|
||||||
version = "1.4.0"
|
version = "1.4.0"
|
||||||
@ -492,6 +511,21 @@ idna = {version = "*", optional = true, markers = "extra == \"idna2008\""}
|
|||||||
[package.extras]
|
[package.extras]
|
||||||
idna2008 = ["idna"]
|
idna2008 = ["idna"]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rich"
|
||||||
|
version = "12.5.1"
|
||||||
|
description = "Render rich text, tables, progress bars, syntax highlighting, markdown and more to the terminal"
|
||||||
|
category = "main"
|
||||||
|
optional = false
|
||||||
|
python-versions = ">=3.6.3,<4.0.0"
|
||||||
|
|
||||||
|
[package.dependencies]
|
||||||
|
commonmark = ">=0.9.0,<0.10.0"
|
||||||
|
pygments = ">=2.6.0,<3.0.0"
|
||||||
|
|
||||||
|
[package.extras]
|
||||||
|
jupyter = ["ipywidgets (>=7.5.1,<8.0.0)"]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "secretstorage"
|
name = "secretstorage"
|
||||||
version = "3.3.2"
|
version = "3.3.2"
|
||||||
@ -597,7 +631,7 @@ python-versions = "*"
|
|||||||
[metadata]
|
[metadata]
|
||||||
lock-version = "1.1"
|
lock-version = "1.1"
|
||||||
python-versions = "^3.10"
|
python-versions = "^3.10"
|
||||||
content-hash = "ccfdeb63811daaa93297ab75bfd661b68b7f04683c8310f0d60783ec56a577cc"
|
content-hash = "996999ee56b557d60dacce8564ac786e41fea036aabedbe3637ca415b6ee959f"
|
||||||
|
|
||||||
[metadata.files]
|
[metadata.files]
|
||||||
anyio = []
|
anyio = []
|
||||||
@ -614,6 +648,10 @@ click = [
|
|||||||
]
|
]
|
||||||
clikit = []
|
clikit = []
|
||||||
colorama = []
|
colorama = []
|
||||||
|
commonmark = [
|
||||||
|
{file = "commonmark-0.9.1-py2.py3-none-any.whl", hash = "sha256:da2f38c92590f83de410ba1a3cbceafbc74fee9def35f9251ba9a971d6d66fd9"},
|
||||||
|
{file = "commonmark-0.9.1.tar.gz", hash = "sha256:452f9dc859be7f06631ddcb328b6919c67984aca654e5fefb3914d54691aed60"},
|
||||||
|
]
|
||||||
crashtest = []
|
crashtest = []
|
||||||
cryptography = []
|
cryptography = []
|
||||||
distlib = []
|
distlib = []
|
||||||
@ -665,6 +703,10 @@ pycparser = [
|
|||||||
{file = "pycparser-2.21-py2.py3-none-any.whl", hash = "sha256:8ee45429555515e1f6b185e78100aea234072576aa43ab53aefcae078162fca9"},
|
{file = "pycparser-2.21-py2.py3-none-any.whl", hash = "sha256:8ee45429555515e1f6b185e78100aea234072576aa43ab53aefcae078162fca9"},
|
||||||
{file = "pycparser-2.21.tar.gz", hash = "sha256:e644fdec12f7872f86c58ff790da456218b10f863970249516d60a5eaca77206"},
|
{file = "pycparser-2.21.tar.gz", hash = "sha256:e644fdec12f7872f86c58ff790da456218b10f863970249516d60a5eaca77206"},
|
||||||
]
|
]
|
||||||
|
pygments = [
|
||||||
|
{file = "Pygments-2.12.0-py3-none-any.whl", hash = "sha256:dc9c10fb40944260f6ed4c688ece0cd2048414940f1cea51b8b226318411c519"},
|
||||||
|
{file = "Pygments-2.12.0.tar.gz", hash = "sha256:5eb116118f9612ff1ee89ac96437bb6b49e8f04d8a13b514ba26f620208e26eb"},
|
||||||
|
]
|
||||||
pylev = []
|
pylev = []
|
||||||
pyparsing = [
|
pyparsing = [
|
||||||
{file = "pyparsing-3.0.9-py3-none-any.whl", hash = "sha256:5026bae9a10eeaefb61dab2f09052b9f4307d44aee4eda64b309723d8d206bbc"},
|
{file = "pyparsing-3.0.9-py3-none-any.whl", hash = "sha256:5026bae9a10eeaefb61dab2f09052b9f4307d44aee4eda64b309723d8d206bbc"},
|
||||||
@ -674,6 +716,10 @@ pywin32-ctypes = []
|
|||||||
requests = []
|
requests = []
|
||||||
requests-toolbelt = []
|
requests-toolbelt = []
|
||||||
rfc3986 = []
|
rfc3986 = []
|
||||||
|
rich = [
|
||||||
|
{file = "rich-12.5.1-py3-none-any.whl", hash = "sha256:2eb4e6894cde1e017976d2975ac210ef515d7548bc595ba20e195fb9628acdeb"},
|
||||||
|
{file = "rich-12.5.1.tar.gz", hash = "sha256:63a5c5ce3673d3d5fbbf23cd87e11ab84b6b451436f1b7f19ec54b6bc36ed7ca"},
|
||||||
|
]
|
||||||
secretstorage = []
|
secretstorage = []
|
||||||
shellingham = []
|
shellingham = []
|
||||||
shiv = []
|
shiv = []
|
||||||
|
@ -9,6 +9,7 @@ python = "^3.10"
|
|||||||
shiv = "^1.0.1"
|
shiv = "^1.0.1"
|
||||||
httpx = "^0.23.0"
|
httpx = "^0.23.0"
|
||||||
click = "^8.1.3"
|
click = "^8.1.3"
|
||||||
|
rich = "^12.5.1"
|
||||||
|
|
||||||
[tool.poetry.dev-dependencies]
|
[tool.poetry.dev-dependencies]
|
||||||
poetry = "^1.1.14"
|
poetry = "^1.1.14"
|
||||||
|
20
src/cli.py
20
src/cli.py
@ -6,6 +6,8 @@ import uuid
|
|||||||
|
|
||||||
import click
|
import click
|
||||||
import httpx
|
import httpx
|
||||||
|
from rich import pretty
|
||||||
|
from rich import print as rprint
|
||||||
from shiv.bootstrap import current_zipfile
|
from shiv.bootstrap import current_zipfile
|
||||||
|
|
||||||
import src
|
import src
|
||||||
@ -22,8 +24,24 @@ from src.art import BANNERS
|
|||||||
def main(ctx):
|
def main(ctx):
|
||||||
"""Launch a utility or drop into a command line REPL if no command is given."""
|
"""Launch a utility or drop into a command line REPL if no command is given."""
|
||||||
if ctx.invoked_subcommand is None:
|
if ctx.invoked_subcommand is None:
|
||||||
|
def print_wrapper(*args, **kwargs):
|
||||||
|
# I know this is dumb.
|
||||||
|
# https://github.com/Textualize/rich/discussions/2462
|
||||||
|
if "crop" in kwargs:
|
||||||
|
del kwargs["crop"]
|
||||||
|
rprint(*args, **kwargs)
|
||||||
|
|
||||||
banner = random.choice(BANNERS)
|
banner = random.choice(BANNERS)
|
||||||
code.interact(banner=banner, local=globals())
|
|
||||||
|
# source of code.interact, just expanded to fit Rich in there
|
||||||
|
console = code.InteractiveConsole(globals())
|
||||||
|
console.print = print_wrapper
|
||||||
|
pretty.install(console) # type: ignore
|
||||||
|
try:
|
||||||
|
import readline
|
||||||
|
except ImportError:
|
||||||
|
pass
|
||||||
|
console.interact(banner, None)
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user