Skip to content

Commit 0b77701

Browse files
authored
fix: some cli issues resolved (#1091)
Noticed these issues, and adding a table of contents like feature. If we expand this in the future, the default should still print out help, so it's forward compatible. Signed-off-by: Henry Schreiner <[email protected]>
1 parent 6fadf30 commit 0b77701

File tree

4 files changed

+47
-4
lines changed

4 files changed

+47
-4
lines changed

docs/reference/cli.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ Scikit-build-core has a few integrated CLI tools. These are not guaranteed to be
44
stable between releases yet, but can still be useful to investigate your
55
environment.
66

7+
```{program-output} python -m scikit_build_core
8+
9+
```
10+
711
## Build utilities
812

913
```{program-output} python -m scikit_build_core.build --help
@@ -36,7 +40,7 @@ Example:
3640
3741
```
3842

39-
## Wheel tag
43+
## Building environment info
4044

4145
```{program-output} python -m scikit_build_core.builder.wheel_tag --help
4246

src/scikit_build_core/__main__.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
from __future__ import annotations
2+
3+
from ._logging import rich_print
4+
5+
__all__ = ["main"]
6+
7+
8+
def __dir__() -> list[str]:
9+
return __all__
10+
11+
12+
def main() -> None:
13+
rich_print("{blue}A top level CLI is not currently provided for scikit-build-core.")
14+
rich_print("{blue}However, the following modules have CLI utilities:")
15+
rich_print(
16+
" python -m scikit_build_core.build requires {green}Get the build requirements"
17+
)
18+
rich_print(
19+
" python -m scikit_build_core.build project-table {green}Get the project table (with dynamic metadata)"
20+
)
21+
rich_print(
22+
" python -m scikit_build_core.builder {green}Info about the system"
23+
)
24+
rich_print(
25+
" python -m scikit_build_core.builder.wheel_tag {green}Info about the computed wheel tag"
26+
)
27+
rich_print(
28+
" python -m scikit_build_core.builder.sysconfig {green}Info from sysconfig"
29+
)
30+
rich_print(
31+
" python -m scikit_build_core.file_api.query {green}Request CMake file API"
32+
)
33+
rich_print(
34+
" python -m scikit_build_core.file_api.reply {green}Process CMake file API"
35+
)
36+
rich_print()
37+
38+
39+
if __name__ == "__main__":
40+
main()

src/scikit_build_core/_logging.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -305,8 +305,7 @@ def rich_print(
305305
``color=`` argument will set a default color to apply to every argument, and
306306
is available to arguments as ``{color}``.
307307
"""
308-
if color:
309-
kwargs["color"] = _style[color]
308+
kwargs["color"] = _style[color] if color else ""
310309

311310
args_1 = tuple(str(arg) for arg in args)
312311
args_1_gen = (

src/scikit_build_core/build/__main__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def main() -> None:
5555
description="Build backend utilities.",
5656
)
5757

58-
subparsers = parser.add_subparsers(help="Commands")
58+
subparsers = parser.add_subparsers(required=True, help="Commands")
5959
requires = subparsers.add_parser(
6060
"requires",
6161
help="Get the build requirements",

0 commit comments

Comments
 (0)