tuiro 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- tuiro-0.1.0/PKG-INFO +202 -0
- tuiro-0.1.0/README.md +184 -0
- tuiro-0.1.0/pyproject.toml +30 -0
- tuiro-0.1.0/src/tuiro/__init__.py +3 -0
- tuiro-0.1.0/src/tuiro/__main__.py +42 -0
- tuiro-0.1.0/src/tuiro/colors.py +49 -0
- tuiro-0.1.0/src/tuiro/palette.py +37 -0
- tuiro-0.1.0/src/tuiro/py.typed +0 -0
- tuiro-0.1.0/src/tuiro/tuiro.py +129 -0
- tuiro-0.1.0/src/tuiro/version.py +1 -0
tuiro-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
|
+
Name: tuiro
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Tiny terminal UI utility for clean, colorful build output.
|
|
5
|
+
Keywords: terminal,tui,ansi,cli,colors,logging,build-tools
|
|
6
|
+
Author: NellowTCS
|
|
7
|
+
Author-email: NellowTCS <nellowtcs@gmail.com>
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
10
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
11
|
+
Classifier: Operating System :: OS Independent
|
|
12
|
+
Classifier: Environment :: Console
|
|
13
|
+
Classifier: Topic :: Terminals
|
|
14
|
+
Classifier: Topic :: Software Development :: Build Tools
|
|
15
|
+
Classifier: Topic :: Utilities
|
|
16
|
+
Requires-Python: >=3.10
|
|
17
|
+
Description-Content-Type: text/markdown
|
|
18
|
+
|
|
19
|
+
# tuiro
|
|
20
|
+
|
|
21
|
+
tuiro is a tiny terminal UI helper designed for clean, readable, and structured output in build scripts and command‑line tools. It provides simple utilities for sections, banners, status messages, command logging, and themed output without introducing heavy dependencies or complex abstractions.
|
|
22
|
+
|
|
23
|
+
> tuiro began as an internal utility inside the TactileBrowser project (https://github.com/NellowTCS/TactileBrowser). It is now available as a standalone library for any script or tool that wants clear and consistent terminal output.
|
|
24
|
+
|
|
25
|
+
## Features
|
|
26
|
+
|
|
27
|
+
- Lightweight and dependency‑free
|
|
28
|
+
- ANSI color support with optional CI mode
|
|
29
|
+
- Built‑in themes and user‑defined palettes
|
|
30
|
+
- Section and subsection headers
|
|
31
|
+
- Informational, warning, success, and error messages
|
|
32
|
+
- Command logging for build steps
|
|
33
|
+
- Centered banners with automatic terminal width detection
|
|
34
|
+
- A simple step context manager for build phases
|
|
35
|
+
- A minimal CLI for quick verification and theme testing
|
|
36
|
+
|
|
37
|
+
## Installation
|
|
38
|
+
|
|
39
|
+
```
|
|
40
|
+
pip install tuiro
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
For development:
|
|
44
|
+
|
|
45
|
+
```
|
|
46
|
+
uv pip install -e .
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Usage
|
|
50
|
+
|
|
51
|
+
Basic example:
|
|
52
|
+
|
|
53
|
+
```python
|
|
54
|
+
from tuiro import TUI
|
|
55
|
+
|
|
56
|
+
tui = TUI()
|
|
57
|
+
tui.banner("Build")
|
|
58
|
+
tui.section("Environment")
|
|
59
|
+
tui.info("Checking dependencies")
|
|
60
|
+
tui.success("All checks passed")
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Example output (colors omitted):
|
|
64
|
+
|
|
65
|
+
```
|
|
66
|
+
╔══════════════════════════════════════════════════════════╗
|
|
67
|
+
║ Build ║
|
|
68
|
+
╚══════════════════════════════════════════════════════════╝
|
|
69
|
+
|
|
70
|
+
────────────────────────────────────────────────────────────
|
|
71
|
+
Environment
|
|
72
|
+
────────────────────────────────────────────────────────────
|
|
73
|
+
[*] Checking dependencies
|
|
74
|
+
[OK] All checks passed
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## Themes
|
|
78
|
+
|
|
79
|
+
tuiro supports both built‑in themes and user‑defined palettes.
|
|
80
|
+
|
|
81
|
+
### Built‑in themes
|
|
82
|
+
|
|
83
|
+
- default
|
|
84
|
+
- mono
|
|
85
|
+
- pastel
|
|
86
|
+
|
|
87
|
+
Use a theme by name:
|
|
88
|
+
|
|
89
|
+
```python
|
|
90
|
+
tui = TUI(theme="pastel")
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### Custom palettes
|
|
94
|
+
|
|
95
|
+
Palettes live in `tuiro.palette`. Users can define their own palette by subclassing `Palette`:
|
|
96
|
+
|
|
97
|
+
```python
|
|
98
|
+
from tuiro.palette import Palette
|
|
99
|
+
from tuiro.colors import Colors
|
|
100
|
+
|
|
101
|
+
class MyPalette(Palette):
|
|
102
|
+
success = Colors.BRIGHT_GREEN
|
|
103
|
+
info = Colors.BRIGHT_CYAN
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
Then pass it to TUI:
|
|
107
|
+
|
|
108
|
+
```python
|
|
109
|
+
tui = TUI(theme=MyPalette)
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
or:
|
|
113
|
+
|
|
114
|
+
```python
|
|
115
|
+
tui = TUI(theme=MyPalette())
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
Note: The CLI `--theme` flag accepts only built‑in theme names from `PROFILES`. Custom palettes must be provided from Python code.
|
|
119
|
+
|
|
120
|
+
## CLI
|
|
121
|
+
|
|
122
|
+
tuiro includes a small demonstration CLI:
|
|
123
|
+
|
|
124
|
+
```
|
|
125
|
+
tuiro
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
Flags:
|
|
129
|
+
|
|
130
|
+
```
|
|
131
|
+
tuiro --ci
|
|
132
|
+
tuiro --no-color
|
|
133
|
+
tuiro --theme pastel
|
|
134
|
+
tuiro --help
|
|
135
|
+
tuiro --version
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
Behavior:
|
|
139
|
+
|
|
140
|
+
- `--ci` disables colors
|
|
141
|
+
- `--no-color` also disables colors
|
|
142
|
+
- If both are provided, colors remain disabled
|
|
143
|
+
- `--theme NAME` selects a built‑in theme
|
|
144
|
+
- `--help` lists available themes
|
|
145
|
+
|
|
146
|
+
Example:
|
|
147
|
+
|
|
148
|
+
```
|
|
149
|
+
tuiro --ci --theme mono
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
## API
|
|
153
|
+
|
|
154
|
+
### `TUI(ci_mode: bool = False, theme: str | Palette = "default")`
|
|
155
|
+
|
|
156
|
+
Creates a new terminal UI helper.
|
|
157
|
+
|
|
158
|
+
### `section(title: str)`
|
|
159
|
+
|
|
160
|
+
Prints a high‑visibility section header.
|
|
161
|
+
|
|
162
|
+
### `subsection(title: str)`
|
|
163
|
+
|
|
164
|
+
Prints a smaller subsection header.
|
|
165
|
+
|
|
166
|
+
### `banner(title: str)`
|
|
167
|
+
|
|
168
|
+
Prints a centered banner.
|
|
169
|
+
|
|
170
|
+
### Status messages
|
|
171
|
+
|
|
172
|
+
```
|
|
173
|
+
info(message: str)
|
|
174
|
+
success(message: str)
|
|
175
|
+
warning(message: str)
|
|
176
|
+
error(message: str)
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
### `command(cmd: str | list[str])`
|
|
180
|
+
|
|
181
|
+
Prints a command being executed. Lists are joined with spaces.
|
|
182
|
+
|
|
183
|
+
### `result(label: str, value: str)`
|
|
184
|
+
|
|
185
|
+
Prints a key‑value result line.
|
|
186
|
+
|
|
187
|
+
### `table(rows: list[tuple[str, str]])`
|
|
188
|
+
|
|
189
|
+
Prints a simple two‑column table aligned on the left column.
|
|
190
|
+
|
|
191
|
+
### `step(title: str)`
|
|
192
|
+
|
|
193
|
+
Context manager for build steps:
|
|
194
|
+
|
|
195
|
+
```python
|
|
196
|
+
with tui.step("Compiling"):
|
|
197
|
+
run_compiler()
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
## License
|
|
201
|
+
|
|
202
|
+
MIT License. See (LICENSE)[LICENSE] for details.
|
tuiro-0.1.0/README.md
ADDED
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
# tuiro
|
|
2
|
+
|
|
3
|
+
tuiro is a tiny terminal UI helper designed for clean, readable, and structured output in build scripts and command‑line tools. It provides simple utilities for sections, banners, status messages, command logging, and themed output without introducing heavy dependencies or complex abstractions.
|
|
4
|
+
|
|
5
|
+
> tuiro began as an internal utility inside the TactileBrowser project (https://github.com/NellowTCS/TactileBrowser). It is now available as a standalone library for any script or tool that wants clear and consistent terminal output.
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
- Lightweight and dependency‑free
|
|
10
|
+
- ANSI color support with optional CI mode
|
|
11
|
+
- Built‑in themes and user‑defined palettes
|
|
12
|
+
- Section and subsection headers
|
|
13
|
+
- Informational, warning, success, and error messages
|
|
14
|
+
- Command logging for build steps
|
|
15
|
+
- Centered banners with automatic terminal width detection
|
|
16
|
+
- A simple step context manager for build phases
|
|
17
|
+
- A minimal CLI for quick verification and theme testing
|
|
18
|
+
|
|
19
|
+
## Installation
|
|
20
|
+
|
|
21
|
+
```
|
|
22
|
+
pip install tuiro
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
For development:
|
|
26
|
+
|
|
27
|
+
```
|
|
28
|
+
uv pip install -e .
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Usage
|
|
32
|
+
|
|
33
|
+
Basic example:
|
|
34
|
+
|
|
35
|
+
```python
|
|
36
|
+
from tuiro import TUI
|
|
37
|
+
|
|
38
|
+
tui = TUI()
|
|
39
|
+
tui.banner("Build")
|
|
40
|
+
tui.section("Environment")
|
|
41
|
+
tui.info("Checking dependencies")
|
|
42
|
+
tui.success("All checks passed")
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Example output (colors omitted):
|
|
46
|
+
|
|
47
|
+
```
|
|
48
|
+
╔══════════════════════════════════════════════════════════╗
|
|
49
|
+
║ Build ║
|
|
50
|
+
╚══════════════════════════════════════════════════════════╝
|
|
51
|
+
|
|
52
|
+
────────────────────────────────────────────────────────────
|
|
53
|
+
Environment
|
|
54
|
+
────────────────────────────────────────────────────────────
|
|
55
|
+
[*] Checking dependencies
|
|
56
|
+
[OK] All checks passed
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Themes
|
|
60
|
+
|
|
61
|
+
tuiro supports both built‑in themes and user‑defined palettes.
|
|
62
|
+
|
|
63
|
+
### Built‑in themes
|
|
64
|
+
|
|
65
|
+
- default
|
|
66
|
+
- mono
|
|
67
|
+
- pastel
|
|
68
|
+
|
|
69
|
+
Use a theme by name:
|
|
70
|
+
|
|
71
|
+
```python
|
|
72
|
+
tui = TUI(theme="pastel")
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### Custom palettes
|
|
76
|
+
|
|
77
|
+
Palettes live in `tuiro.palette`. Users can define their own palette by subclassing `Palette`:
|
|
78
|
+
|
|
79
|
+
```python
|
|
80
|
+
from tuiro.palette import Palette
|
|
81
|
+
from tuiro.colors import Colors
|
|
82
|
+
|
|
83
|
+
class MyPalette(Palette):
|
|
84
|
+
success = Colors.BRIGHT_GREEN
|
|
85
|
+
info = Colors.BRIGHT_CYAN
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Then pass it to TUI:
|
|
89
|
+
|
|
90
|
+
```python
|
|
91
|
+
tui = TUI(theme=MyPalette)
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
or:
|
|
95
|
+
|
|
96
|
+
```python
|
|
97
|
+
tui = TUI(theme=MyPalette())
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
Note: The CLI `--theme` flag accepts only built‑in theme names from `PROFILES`. Custom palettes must be provided from Python code.
|
|
101
|
+
|
|
102
|
+
## CLI
|
|
103
|
+
|
|
104
|
+
tuiro includes a small demonstration CLI:
|
|
105
|
+
|
|
106
|
+
```
|
|
107
|
+
tuiro
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
Flags:
|
|
111
|
+
|
|
112
|
+
```
|
|
113
|
+
tuiro --ci
|
|
114
|
+
tuiro --no-color
|
|
115
|
+
tuiro --theme pastel
|
|
116
|
+
tuiro --help
|
|
117
|
+
tuiro --version
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
Behavior:
|
|
121
|
+
|
|
122
|
+
- `--ci` disables colors
|
|
123
|
+
- `--no-color` also disables colors
|
|
124
|
+
- If both are provided, colors remain disabled
|
|
125
|
+
- `--theme NAME` selects a built‑in theme
|
|
126
|
+
- `--help` lists available themes
|
|
127
|
+
|
|
128
|
+
Example:
|
|
129
|
+
|
|
130
|
+
```
|
|
131
|
+
tuiro --ci --theme mono
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
## API
|
|
135
|
+
|
|
136
|
+
### `TUI(ci_mode: bool = False, theme: str | Palette = "default")`
|
|
137
|
+
|
|
138
|
+
Creates a new terminal UI helper.
|
|
139
|
+
|
|
140
|
+
### `section(title: str)`
|
|
141
|
+
|
|
142
|
+
Prints a high‑visibility section header.
|
|
143
|
+
|
|
144
|
+
### `subsection(title: str)`
|
|
145
|
+
|
|
146
|
+
Prints a smaller subsection header.
|
|
147
|
+
|
|
148
|
+
### `banner(title: str)`
|
|
149
|
+
|
|
150
|
+
Prints a centered banner.
|
|
151
|
+
|
|
152
|
+
### Status messages
|
|
153
|
+
|
|
154
|
+
```
|
|
155
|
+
info(message: str)
|
|
156
|
+
success(message: str)
|
|
157
|
+
warning(message: str)
|
|
158
|
+
error(message: str)
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
### `command(cmd: str | list[str])`
|
|
162
|
+
|
|
163
|
+
Prints a command being executed. Lists are joined with spaces.
|
|
164
|
+
|
|
165
|
+
### `result(label: str, value: str)`
|
|
166
|
+
|
|
167
|
+
Prints a key‑value result line.
|
|
168
|
+
|
|
169
|
+
### `table(rows: list[tuple[str, str]])`
|
|
170
|
+
|
|
171
|
+
Prints a simple two‑column table aligned on the left column.
|
|
172
|
+
|
|
173
|
+
### `step(title: str)`
|
|
174
|
+
|
|
175
|
+
Context manager for build steps:
|
|
176
|
+
|
|
177
|
+
```python
|
|
178
|
+
with tui.step("Compiling"):
|
|
179
|
+
run_compiler()
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
## License
|
|
183
|
+
|
|
184
|
+
MIT License. See (LICENSE)[LICENSE] for details.
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "tuiro"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
description = "Tiny terminal UI utility for clean, colorful build output."
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
authors = [
|
|
7
|
+
{ name = "NellowTCS", email = "nellowtcs@gmail.com" }
|
|
8
|
+
]
|
|
9
|
+
requires-python = ">=3.10"
|
|
10
|
+
dependencies = []
|
|
11
|
+
|
|
12
|
+
keywords = ["terminal", "tui", "ansi", "cli", "colors", "logging", "build-tools"]
|
|
13
|
+
|
|
14
|
+
classifiers = [
|
|
15
|
+
"Programming Language :: Python :: 3",
|
|
16
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
17
|
+
"License :: OSI Approved :: MIT License",
|
|
18
|
+
"Operating System :: OS Independent",
|
|
19
|
+
"Environment :: Console",
|
|
20
|
+
"Topic :: Terminals",
|
|
21
|
+
"Topic :: Software Development :: Build Tools",
|
|
22
|
+
"Topic :: Utilities"
|
|
23
|
+
]
|
|
24
|
+
|
|
25
|
+
[build-system]
|
|
26
|
+
requires = ["uv_build>=0.10.2,<0.11.0"]
|
|
27
|
+
build-backend = "uv_build"
|
|
28
|
+
|
|
29
|
+
[project.scripts]
|
|
30
|
+
tuiro = "tuiro.__main__:main"
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import sys
|
|
2
|
+
from . import TUI
|
|
3
|
+
from .version import __version__
|
|
4
|
+
from .palette import Palette, PROFILES
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def main():
|
|
8
|
+
args = sys.argv[1:]
|
|
9
|
+
|
|
10
|
+
# Help
|
|
11
|
+
if "--help" in args or "-h" in args:
|
|
12
|
+
print("Usage: tuiro [--ci] [--no-color] [--theme NAME] [--help] [--version]")
|
|
13
|
+
print("Available themes:", ", ".join(PROFILES.keys()))
|
|
14
|
+
return
|
|
15
|
+
|
|
16
|
+
# Version
|
|
17
|
+
if "--version" in args:
|
|
18
|
+
print(f"tuiro {__version__}")
|
|
19
|
+
return
|
|
20
|
+
|
|
21
|
+
# Flags
|
|
22
|
+
force_ci = "--ci" in args
|
|
23
|
+
force_no_color = "--no-color" in args
|
|
24
|
+
|
|
25
|
+
# Theme
|
|
26
|
+
theme = "default"
|
|
27
|
+
if "--theme" in args:
|
|
28
|
+
idx = args.index("--theme")
|
|
29
|
+
if idx + 1 < len(args):
|
|
30
|
+
theme = args[idx + 1]
|
|
31
|
+
|
|
32
|
+
ci_mode = force_ci or force_no_color
|
|
33
|
+
|
|
34
|
+
tui = TUI(ci_mode=ci_mode, theme=theme)
|
|
35
|
+
|
|
36
|
+
tui.banner("tuiro")
|
|
37
|
+
tui.section("Demo")
|
|
38
|
+
tui.success("tuiro is installed and working!")
|
|
39
|
+
tui.error("There is no error")
|
|
40
|
+
tui.info("You are ready to build clean CLI scripts.")
|
|
41
|
+
if ci_mode:
|
|
42
|
+
tui.warning("CI mode active")
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
|
|
2
|
+
class Colors:
|
|
3
|
+
"""ANSI color codes."""
|
|
4
|
+
RESET = "\033[0m"
|
|
5
|
+
BOLD = "\033[1m"
|
|
6
|
+
DIM = "\033[2m"
|
|
7
|
+
|
|
8
|
+
# Foreground colors
|
|
9
|
+
BLACK = "\033[30m"
|
|
10
|
+
RED = "\033[31m"
|
|
11
|
+
GREEN = "\033[32m"
|
|
12
|
+
YELLOW = "\033[33m"
|
|
13
|
+
BLUE = "\033[34m"
|
|
14
|
+
MAGENTA = "\033[35m"
|
|
15
|
+
CYAN = "\033[36m"
|
|
16
|
+
WHITE = "\033[37m"
|
|
17
|
+
|
|
18
|
+
# Bright foreground colors
|
|
19
|
+
BRIGHT_BLACK = "\033[90m"
|
|
20
|
+
BRIGHT_RED = "\033[91m"
|
|
21
|
+
BRIGHT_GREEN = "\033[92m"
|
|
22
|
+
BRIGHT_YELLOW = "\033[93m"
|
|
23
|
+
BRIGHT_BLUE = "\033[94m"
|
|
24
|
+
BRIGHT_MAGENTA = "\033[95m"
|
|
25
|
+
BRIGHT_CYAN = "\033[96m"
|
|
26
|
+
BRIGHT_WHITE = "\033[97m"
|
|
27
|
+
|
|
28
|
+
@staticmethod
|
|
29
|
+
def disable():
|
|
30
|
+
"""Disable all colors."""
|
|
31
|
+
Colors.RESET = ""
|
|
32
|
+
Colors.BOLD = ""
|
|
33
|
+
Colors.DIM = ""
|
|
34
|
+
Colors.BLACK = ""
|
|
35
|
+
Colors.RED = ""
|
|
36
|
+
Colors.GREEN = ""
|
|
37
|
+
Colors.YELLOW = ""
|
|
38
|
+
Colors.BLUE = ""
|
|
39
|
+
Colors.MAGENTA = ""
|
|
40
|
+
Colors.CYAN = ""
|
|
41
|
+
Colors.WHITE = ""
|
|
42
|
+
Colors.BRIGHT_BLACK = ""
|
|
43
|
+
Colors.BRIGHT_RED = ""
|
|
44
|
+
Colors.BRIGHT_GREEN = ""
|
|
45
|
+
Colors.BRIGHT_YELLOW = ""
|
|
46
|
+
Colors.BRIGHT_BLUE = ""
|
|
47
|
+
Colors.BRIGHT_MAGENTA = ""
|
|
48
|
+
Colors.BRIGHT_CYAN = ""
|
|
49
|
+
Colors.BRIGHT_WHITE = ""
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
from .colors import Colors
|
|
2
|
+
|
|
3
|
+
class Palette:
|
|
4
|
+
"""Base color palette for tuiro."""
|
|
5
|
+
info = Colors.CYAN
|
|
6
|
+
success = Colors.GREEN
|
|
7
|
+
warning = Colors.YELLOW
|
|
8
|
+
error = Colors.RED
|
|
9
|
+
accent = Colors.BRIGHT_BLUE
|
|
10
|
+
dim = Colors.DIM
|
|
11
|
+
text = Colors.BRIGHT_WHITE
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class Mono(Palette):
|
|
15
|
+
"""Monochrome palette."""
|
|
16
|
+
info = Colors.WHITE
|
|
17
|
+
success = Colors.WHITE
|
|
18
|
+
warning = Colors.WHITE
|
|
19
|
+
error = Colors.WHITE
|
|
20
|
+
accent = Colors.WHITE
|
|
21
|
+
text = Colors.WHITE
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class Pastel(Palette):
|
|
25
|
+
"""pristine pastel palette."""
|
|
26
|
+
info = Colors.BRIGHT_CYAN
|
|
27
|
+
success = Colors.BRIGHT_GREEN
|
|
28
|
+
warning = Colors.BRIGHT_YELLOW
|
|
29
|
+
error = Colors.BRIGHT_MAGENTA
|
|
30
|
+
accent = Colors.BRIGHT_BLUE
|
|
31
|
+
text = Colors.BRIGHT_WHITE
|
|
32
|
+
|
|
33
|
+
PROFILES = {
|
|
34
|
+
"default": Palette,
|
|
35
|
+
"mono": Mono,
|
|
36
|
+
"pastel": Pastel,
|
|
37
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
"""tuiro: tiny terminal UI utility for clean, colorful build output."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import shutil
|
|
6
|
+
import sys
|
|
7
|
+
from contextlib import contextmanager
|
|
8
|
+
from .colors import Colors
|
|
9
|
+
from .palette import PROFILES, Palette
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class TUI:
|
|
13
|
+
"""Core TUI class for the tuiro terminal UI library.
|
|
14
|
+
|
|
15
|
+
Provides structured terminal output for build scripts,
|
|
16
|
+
developer tooling, and lightweight CLIs.
|
|
17
|
+
"""
|
|
18
|
+
|
|
19
|
+
def __init__(self, ci_mode: bool = False, theme: str | Palette = "default") -> None:
|
|
20
|
+
"""Initialize the TUI.
|
|
21
|
+
|
|
22
|
+
Args:
|
|
23
|
+
ci_mode: If True, disable colors.
|
|
24
|
+
theme: A theme name or a Palette subclass.
|
|
25
|
+
"""
|
|
26
|
+
self.ci_mode = ci_mode
|
|
27
|
+
|
|
28
|
+
if isinstance(theme, str):
|
|
29
|
+
theme_cls = PROFILES.get(theme, PROFILES["default"])
|
|
30
|
+
self.palette = theme_cls()
|
|
31
|
+
else:
|
|
32
|
+
self.palette = theme()
|
|
33
|
+
|
|
34
|
+
if ci_mode or not sys.stdout.isatty():
|
|
35
|
+
Colors.disable()
|
|
36
|
+
|
|
37
|
+
# ------------------------------------------------------------
|
|
38
|
+
# Sections and headings
|
|
39
|
+
# ------------------------------------------------------------
|
|
40
|
+
|
|
41
|
+
def section(self, title: str) -> None:
|
|
42
|
+
width = shutil.get_terminal_size().columns
|
|
43
|
+
width = max(40, min(width, 120))
|
|
44
|
+
line = "─" * width
|
|
45
|
+
c = self.palette.accent
|
|
46
|
+
print(f"\n{c}{Colors.BOLD}{line}{Colors.RESET}")
|
|
47
|
+
print(f"{c}{Colors.BOLD} {title}{Colors.RESET}")
|
|
48
|
+
print(f"{c}{Colors.BOLD}{line}{Colors.RESET}")
|
|
49
|
+
|
|
50
|
+
def subsection(self, title: str) -> None:
|
|
51
|
+
c = self.palette.accent
|
|
52
|
+
print(f"\n{c}{Colors.BOLD}▶ {title}{Colors.RESET}")
|
|
53
|
+
|
|
54
|
+
# ------------------------------------------------------------
|
|
55
|
+
# Message types
|
|
56
|
+
# ------------------------------------------------------------
|
|
57
|
+
|
|
58
|
+
def success(self, message: str) -> None:
|
|
59
|
+
print(f"{self.palette.success}[OK]{Colors.RESET} {message}")
|
|
60
|
+
|
|
61
|
+
def info(self, message: str) -> None:
|
|
62
|
+
print(f"{self.palette.info}[*]{Colors.RESET} {message}")
|
|
63
|
+
|
|
64
|
+
def warning(self, message: str) -> None:
|
|
65
|
+
print(f"{self.palette.warning}[!]{Colors.RESET} {message}")
|
|
66
|
+
|
|
67
|
+
def error(self, message: str) -> None:
|
|
68
|
+
print(f"{self.palette.error}[ERROR]{Colors.RESET} {message}")
|
|
69
|
+
|
|
70
|
+
# ------------------------------------------------------------
|
|
71
|
+
# Utility output
|
|
72
|
+
# ------------------------------------------------------------
|
|
73
|
+
|
|
74
|
+
def command(self, cmd: str | list[str]) -> None:
|
|
75
|
+
cmd_str = " ".join(cmd) if isinstance(cmd, list) else cmd
|
|
76
|
+
print(f"{self.palette.dim}$ {cmd_str}{Colors.RESET}")
|
|
77
|
+
|
|
78
|
+
def result(self, label: str, value: str) -> None:
|
|
79
|
+
print(f"{self.palette.text}{label}:{Colors.RESET} {value}")
|
|
80
|
+
|
|
81
|
+
def table(self, rows: list[tuple[str, str]]) -> None:
|
|
82
|
+
if not rows:
|
|
83
|
+
return
|
|
84
|
+
left_width = max(len(label) for label, _ in rows)
|
|
85
|
+
for label, value in rows:
|
|
86
|
+
print(f"{label.ljust(left_width)} {value}")
|
|
87
|
+
|
|
88
|
+
# ------------------------------------------------------------
|
|
89
|
+
# Banner
|
|
90
|
+
# ------------------------------------------------------------
|
|
91
|
+
|
|
92
|
+
def banner(self, title: str) -> None:
|
|
93
|
+
width = shutil.get_terminal_size().columns
|
|
94
|
+
width = max(40, min(width, 120))
|
|
95
|
+
c = self.palette.accent
|
|
96
|
+
|
|
97
|
+
print(f"\n{c}{Colors.BOLD}")
|
|
98
|
+
print("╔" + "═" * (width - 2) + "╗")
|
|
99
|
+
padding = (width - 2 - len(title)) // 2
|
|
100
|
+
print(
|
|
101
|
+
"║"
|
|
102
|
+
+ " " * padding
|
|
103
|
+
+ title
|
|
104
|
+
+ " " * (width - 2 - padding - len(title))
|
|
105
|
+
+ "║"
|
|
106
|
+
)
|
|
107
|
+
print("╚" + "═" * (width - 2) + "╝")
|
|
108
|
+
print(f"{Colors.RESET}")
|
|
109
|
+
|
|
110
|
+
# ------------------------------------------------------------
|
|
111
|
+
# Step context manager
|
|
112
|
+
# ------------------------------------------------------------
|
|
113
|
+
|
|
114
|
+
@contextmanager
|
|
115
|
+
def step(self, title: str):
|
|
116
|
+
self.info(f"{title}...")
|
|
117
|
+
try:
|
|
118
|
+
yield
|
|
119
|
+
self.success(f"{title} completed")
|
|
120
|
+
except Exception:
|
|
121
|
+
self.error(f"{title} failed")
|
|
122
|
+
raise
|
|
123
|
+
|
|
124
|
+
# ------------------------------------------------------------
|
|
125
|
+
# Representation
|
|
126
|
+
# ------------------------------------------------------------
|
|
127
|
+
|
|
128
|
+
def __repr__(self) -> str:
|
|
129
|
+
return "<tuiro.TUI: aesthetic terminal UI helper>"
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.1.0"
|