Skip to content

Commit 9db5443

Browse files
Add rich help panels to CLI (#572)
* Add rich help panels to CLI * uv add typer>=0.6.0
1 parent c919768 commit 9db5443

4 files changed

Lines changed: 741 additions & 708 deletions

File tree

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ dependencies = [
4343
"rich>=9.6.1",
4444
"ruamel-yaml>=0.16.13",
4545
"tomlkit>=0.12.0",
46-
"typer>=0.4.1",
46+
"typer>=0.6.0",
4747
"typing-extensions>=3.10.0.0",
4848
]
4949
scripts.usethis = "usethis.__main__:app"

src/usethis/_app.py

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,23 +20,40 @@
2020
),
2121
add_completion=False,
2222
)
23-
app.command(help="Add an author to the project.")(
23+
24+
rich_help_panel = "Manage Tooling"
25+
app.add_typer(usethis._interface.ci.app, name="ci", rich_help_panel=rich_help_panel)
26+
app.add_typer(usethis._interface.tool.app, name="tool", rich_help_panel=rich_help_panel)
27+
28+
rich_help_panel = "Manage Config"
29+
app.command(help="Add an author to the project.", rich_help_panel=rich_help_panel)(
2430
usethis._interface.author.author,
2531
)
26-
app.add_typer(usethis._interface.badge.app, name="badge")
27-
app.add_typer(usethis._interface.browse.app, name="browse")
28-
app.add_typer(usethis._interface.ci.app, name="ci")
29-
app.command(help="Add a README.md file to the project.")(
32+
app.command(help="Enforce a docstring style.", rich_help_panel=rich_help_panel)(
33+
usethis._interface.docstyle.docstyle,
34+
)
35+
36+
rich_help_panel = "Manage README"
37+
app.add_typer(
38+
usethis._interface.badge.app, name="badge", rich_help_panel=rich_help_panel
39+
)
40+
app.command(
41+
help="Add a README.md file to the project.", rich_help_panel=rich_help_panel
42+
)(
3043
usethis._interface.readme.readme,
3144
)
32-
app.command(help="Enforce a docstring style.")(
33-
usethis._interface.docstyle.docstyle,
45+
46+
rich_help_panel = "Informative"
47+
app.add_typer(
48+
usethis._interface.browse.app, name="browse", rich_help_panel=rich_help_panel
3449
)
35-
app.command(help="List usage of tooling and config managed by usethis.")(
50+
app.command(
51+
help="List usage of tooling and config managed by usethis.",
52+
rich_help_panel=rich_help_panel,
53+
)(
3654
usethis._interface.list.list,
3755
)
38-
app.add_typer(usethis._interface.show.app, name="show")
39-
app.add_typer(usethis._interface.tool.app, name="tool")
40-
app.command(help="Display the version of usethis.")(
56+
app.add_typer(usethis._interface.show.app, name="show", rich_help_panel=rich_help_panel)
57+
app.command(help="Display the version of usethis.", rich_help_panel=rich_help_panel)(
4158
usethis._interface.version.version,
4259
)

src/usethis/_interface/tool.py

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
@app.command(
3434
name="codespell",
3535
help="Use the codespell spellchecker: detect common spelling mistakes.",
36+
rich_help_panel="Code Quality Tools",
3637
)
3738
def codespell(
3839
remove: bool = remove_opt,
@@ -47,7 +48,11 @@ def codespell(
4748
_run_tool(use_codespell, remove=remove)
4849

4950

50-
@app.command(name="coverage", help="Use coverage: a code coverage measurement tool.")
51+
@app.command(
52+
name="coverage",
53+
help="Use coverage: a code coverage measurement tool.",
54+
rich_help_panel="Testing",
55+
)
5156
def coverage(
5257
remove: bool = remove_opt,
5358
offline: bool = offline_opt,
@@ -64,6 +69,7 @@ def coverage(
6469
@app.command(
6570
name="deptry",
6671
help="Use the deptry linter: avoid missing or superfluous dependency declarations.",
72+
rich_help_panel="Code Quality Tools",
6773
)
6874
def deptry(
6975
remove: bool = remove_opt,
@@ -81,6 +87,7 @@ def deptry(
8187
@app.command(
8288
name="import-linter",
8389
help="Use Import Linter: enforce a self-imposed architecture on imports.",
90+
rich_help_panel="Code Quality Tools",
8491
)
8592
def import_linter(
8693
remove: bool = remove_opt,
@@ -98,6 +105,7 @@ def import_linter(
98105
@app.command(
99106
name="pre-commit",
100107
help="Use the pre-commit framework to manage and maintain pre-commit hooks.",
108+
rich_help_panel="Code Quality Tools",
101109
)
102110
def pre_commit(
103111
remove: bool = remove_opt,
@@ -115,6 +123,7 @@ def pre_commit(
115123
@app.command(
116124
name="pyproject-fmt",
117125
help="Use the pyproject-fmt linter: opinionated formatting of 'pyproject.toml' files.",
126+
rich_help_panel="Code Quality Tools",
118127
)
119128
def pyproject_fmt(
120129
remove: bool = remove_opt,
@@ -130,7 +139,9 @@ def pyproject_fmt(
130139

131140

132141
@app.command(
133-
name="pyproject.toml", help="Use a pyproject.toml file to configure the project."
142+
name="pyproject.toml",
143+
help="Use a pyproject.toml file to configure the project.",
144+
rich_help_panel="Configuration Files",
134145
)
135146
def pyproject_toml(
136147
remove: bool = remove_opt,
@@ -145,7 +156,9 @@ def pyproject_toml(
145156
_run_tool(use_pyproject_toml, remove=remove)
146157

147158

148-
@app.command(name="pytest", help="Use the pytest testing framework.")
159+
@app.command(
160+
name="pytest", help="Use the pytest testing framework.", rich_help_panel="Testing"
161+
)
149162
def pytest(
150163
remove: bool = remove_opt,
151164
offline: bool = offline_opt,
@@ -162,6 +175,7 @@ def pytest(
162175
@app.command(
163176
name="requirements.txt",
164177
help="Use a requirements.txt file exported from the uv lockfile.",
178+
rich_help_panel="Configuration Files",
165179
)
166180
def requirements_txt(
167181
remove: bool = remove_opt,
@@ -177,7 +191,9 @@ def requirements_txt(
177191

178192

179193
@app.command(
180-
name="ruff", help="Use Ruff: an extremely fast Python linter and code formatter."
194+
name="ruff",
195+
help="Use Ruff: an extremely fast Python linter and code formatter.",
196+
rich_help_panel="Code Quality Tools",
181197
)
182198
def ruff(
183199
remove: bool = remove_opt,

0 commit comments

Comments
 (0)