Closed nathanscain closed 2 months ago
Isn't this already available using rich-cli?
Isn't this already available using rich-cli?
Amazingly, this is the first (at least that I remember) time I'm hearing about rich-cli
. Based on a quick look, that looks like what I was needing.
Up to you if you want to keep this or not, but seems like that is the preferred method. What if we just strip away everything except the note on the introduction docs page that explains how you'd run it directly using rich-cli
? (Because I've used rich for years and have a few applications that might end up using textualize, but I never knew you had this.)
Type of changes
Checklist
Description
I was trying to use rich's terminal rendering of markdown files earlier today, but the project wasn't using rich so
python -m rich.markdown
wouldn't work without me editing my virtual environment to include items that weren't listed in mypyproject.toml
configuration. Typically I'd solve this by installing the package as a tool that has globally callable commands, but rich doesn't currently export any commands.This PR adds
tool.poetry.scripts
entries for each of the 3 directly usable commands (markdown, syntax, and json). This required moving the content currently underif __name__ == "__main__":
sections to be under a protected_main
method so that both the scripts and module (python -m
) entrypoints would execute the same code.Now users can use
uv
orpipx
to install rich as a tool so that these commands are always available:I'm open to whatever naming convention you'd prefer. Currently the commands are
rich.markdown
,rich.syntax
, andrich.json
to mirror the module entrypoints, but these could also berich-markdown
,rich-syntax
, andrich-json
(or anything else — the only limiting factors are that they shouldn't have spaces and should be clearly tied to rich since the goal is for them to be installed globally without conflicts.)The change is documented based on the surrounding style. I wasn't able to test building the documentation due a resolution error within the provided
requirements.txt
: