mmit-clitheme 0.15.0__py3-none-any.whl
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.
- cli_theme/__init__.py +47 -0
- cli_theme/arguments.py +265 -0
- cli_theme/bash/cli.lib.sh +475 -0
- cli_theme/bash/make.lib.sh +138 -0
- cli_theme/cli.py +276 -0
- cli_theme/deno/deno.json +10 -0
- cli_theme/deno/help.ts +150 -0
- cli_theme/deno/mod.ts +413 -0
- cli_theme/export.py +221 -0
- cli_theme/i18n.py +18 -0
- cli_theme/locales/de/LC_MESSAGES/cli_theme.mo +0 -0
- cli_theme/locales/de/LC_MESSAGES/cli_theme.po +328 -0
- cli_theme/output.py +261 -0
- cli_theme/skill.py +107 -0
- cli_theme/templates/classic.theme +46 -0
- cli_theme/templates/earth.theme +46 -0
- cli_theme/templates/forest.theme +46 -0
- cli_theme/templates/mono.theme +46 -0
- cli_theme/templates/neon.theme +46 -0
- cli_theme/templates/night.theme +46 -0
- cli_theme/templates/ocean.theme +46 -0
- cli_theme/templates/shell.theme +46 -0
- cli_theme/templates/sunset.theme +46 -0
- cli_theme/theme.py +422 -0
- mmit_clitheme-0.15.0.data/scripts/clilib-path +74 -0
- mmit_clitheme-0.15.0.dist-info/METADATA +482 -0
- mmit_clitheme-0.15.0.dist-info/RECORD +33 -0
- mmit_clitheme-0.15.0.dist-info/WHEEL +5 -0
- mmit_clitheme-0.15.0.dist-info/entry_points.txt +3 -0
- mmit_clitheme-0.15.0.dist-info/licenses/LICENSE +287 -0
- mmit_clitheme-0.15.0.dist-info/licenses/LICENSE.de.txt +101 -0
- mmit_clitheme-0.15.0.dist-info/licenses/LICENSING.md +97 -0
- mmit_clitheme-0.15.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,482 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: mmit-clitheme
|
|
3
|
+
Version: 0.15.0
|
|
4
|
+
Summary: Shared CLI theme for Python, Bash and Make: read the theme file, rich styles and spacing
|
|
5
|
+
Author-email: Michael Mitterer <office@MangoLila.at>
|
|
6
|
+
License-Expression: EUPL-1.2
|
|
7
|
+
Project-URL: Homepage, https://github.com/MikeMitterer/python-clitheme
|
|
8
|
+
Classifier: Development Status :: 4 - Beta
|
|
9
|
+
Classifier: Environment :: Console
|
|
10
|
+
Classifier: Intended Audience :: Developers
|
|
11
|
+
Classifier: Operating System :: MacOS
|
|
12
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
19
|
+
Classifier: Topic :: Terminals
|
|
20
|
+
Requires-Python: >=3.11
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
License-File: LICENSE
|
|
23
|
+
License-File: LICENSE.de.txt
|
|
24
|
+
License-File: LICENSING.md
|
|
25
|
+
Requires-Dist: rich>=15
|
|
26
|
+
Provides-Extra: dev
|
|
27
|
+
Requires-Dist: pytest; extra == "dev"
|
|
28
|
+
Requires-Dist: ruff; extra == "dev"
|
|
29
|
+
Requires-Dist: babel; extra == "dev"
|
|
30
|
+
Requires-Dist: setuptools>=77; extra == "dev"
|
|
31
|
+
Requires-Dist: build; extra == "dev"
|
|
32
|
+
Requires-Dist: twine; extra == "dev"
|
|
33
|
+
Dynamic: license-file
|
|
34
|
+
|
|
35
|
+
<div align="center">
|
|
36
|
+
|
|
37
|
+
# CLITheme
|
|
38
|
+
|
|
39
|
+
**One theme file for the colors and spacing of Python, Bash and Make output**
|
|
40
|
+
|
|
41
|
+
[Example](#example) · [Quick start](#quick-start) · [Theme file](#theme-file) · [Use](#use) · [Development](https://github.com/MikeMitterer/python-clitheme/blob/master/docs/development.md)
|
|
42
|
+
|
|
43
|
+
English · [Deutsch](README.de.md)
|
|
44
|
+
|
|
45
|
+
</div>
|
|
46
|
+
|
|
47
|
+
CLITheme keeps the colors and spacing of command line output in one small
|
|
48
|
+
file per theme. Python tools read it through the package `mmit-clitheme`;
|
|
49
|
+
Bash scripts and Makefiles get the resolved values from `clitheme export`,
|
|
50
|
+
checked by the same rules. The command `clitheme` installs the bundled
|
|
51
|
+
themes, prints the path of the chosen one, shows its roles and spacing and
|
|
52
|
+
exports them for Bash and Make.
|
|
53
|
+
|
|
54
|
+
## Contents
|
|
55
|
+
|
|
56
|
+
- [Example](#example)
|
|
57
|
+
- [Features](#features)
|
|
58
|
+
- [Quick start](#quick-start)
|
|
59
|
+
- [Theme file](#theme-file)
|
|
60
|
+
- [Use](#use)
|
|
61
|
+
- [Development](#development)
|
|
62
|
+
- [License](#license)
|
|
63
|
+
|
|
64
|
+
## Example
|
|
65
|
+
|
|
66
|
+
```python
|
|
67
|
+
from cli_theme import Output
|
|
68
|
+
|
|
69
|
+
with Output() as out:
|
|
70
|
+
out.head("Repository")
|
|
71
|
+
out.row("Branch", "master")
|
|
72
|
+
out.row("Status", "clean")
|
|
73
|
+
out.hint("Nothing to commit.")
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
In a terminal the heading, labels and values appear in the colors of the
|
|
77
|
+
chosen theme, aligned in two columns. In pipes, with `NO_COLOR` or with
|
|
78
|
+
`TERM=dumb` the same text appears without colors and with the same spacing.
|
|
79
|
+
At the end of the `with` block a blank line closes the output, so the next
|
|
80
|
+
prompt does not stick to it.
|
|
81
|
+
|
|
82
|
+
[↑ Contents](#contents)
|
|
83
|
+
|
|
84
|
+
## Features
|
|
85
|
+
|
|
86
|
+
- **Theme file:** colors for ten roles and seven spacing values as
|
|
87
|
+
`NAME=value` lines, readable by Python, Bash and Make.
|
|
88
|
+
- **Nine themes:** classic, ocean, earth, night, mono, sunset, forest, neon
|
|
89
|
+
and shell; `clitheme use` switches between them, `CLI_THEME` overrides
|
|
90
|
+
the choice.
|
|
91
|
+
- **Checked reading:** invalid or missing entries are reported with file and
|
|
92
|
+
line; a missing file means no colors and the spacing of classic.
|
|
93
|
+
- **rich styles:** the color of each role as a [rich](https://github.com/Textualize/rich)
|
|
94
|
+
style, ready for your own output.
|
|
95
|
+
- **Output helpers:** `head()`, `row()` and `hint()` wrap long lines at
|
|
96
|
+
`WIDTH` or the terminal width; `write(..., wrap=False)` keeps a line whole.
|
|
97
|
+
- **Help in theme colors:** `ArgumentParser` lays out its help like
|
|
98
|
+
`Output`: headings, options and descriptions in the theme's colors and
|
|
99
|
+
columns, plus sections of your own such as a command list.
|
|
100
|
+
- **Closing blank line:** `Output` and `ArgumentParser` end output, help and
|
|
101
|
+
error messages with one blank line.
|
|
102
|
+
- **Export for Bash, Make and other languages:** `clitheme export` resolves
|
|
103
|
+
the theme into `THEME_*` variables (escape sequences, indents, widths), as
|
|
104
|
+
shell assignments, a `.mk` file or JSON, and caches them.
|
|
105
|
+
- **Deno package:** `@mmit/clitheme` comes with clitheme and prints
|
|
106
|
+
headings, rows, status lines and a `--help` like `changelog` from
|
|
107
|
+
ProjectTools; `clitheme export --deno` names its `mod.ts`.
|
|
108
|
+
- **Bash library:** `cli.lib.sh` prints headings, rows, values, hints and
|
|
109
|
+
status lines in the theme, the same functions as in BashLib, without
|
|
110
|
+
BashLib; `clilib-path` names its folder.
|
|
111
|
+
- **`clitheme` command:** `install`, `list`, `use`, `path`, `show` and
|
|
112
|
+
`export`, in English or German depending on the locale.
|
|
113
|
+
- **Description for AI agents:** `clitheme --skill` prints the commands with
|
|
114
|
+
what they change and when to use them as Markdown, without colors.
|
|
115
|
+
|
|
116
|
+
[↑ Contents](#contents)
|
|
117
|
+
|
|
118
|
+
## Quick start
|
|
119
|
+
|
|
120
|
+
Requirements: Python 3.11 or later and [pipx](https://pipx.pypa.io/).
|
|
121
|
+
|
|
122
|
+
**Install** from PyPI, then create the theme files:
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
pipx install mmit-clitheme
|
|
126
|
+
clitheme install
|
|
127
|
+
clitheme show
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
`install` creates every missing theme file and leaves existing ones
|
|
131
|
+
unchanged, so your own changes stay. **Update:** `pipx upgrade
|
|
132
|
+
mmit-clitheme`. If you work on CLITheme itself, install the working copy as
|
|
133
|
+
described in the [developer documentation](https://github.com/MikeMitterer/python-clitheme/blob/master/docs/development.md#einrichten);
|
|
134
|
+
changes then take effect without reinstalling.
|
|
135
|
+
|
|
136
|
+
**A specific release from Git:** tags follow the scheme
|
|
137
|
+
`vX.Y.Z+YYMMDD.HHMM.hash`, and pipx needs the full tag. This command shows
|
|
138
|
+
the latest one; replace `<release-tag>` with it:
|
|
139
|
+
|
|
140
|
+
```bash
|
|
141
|
+
git ls-remote --tags --refs --sort=-v:refname https://github.com/MikeMitterer/python-clitheme.git | head -1
|
|
142
|
+
pipx install 'git+https://github.com/MikeMitterer/python-clitheme.git@<release-tag>'
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
To update, run the same `pipx install` with `--force` and the new full tag.
|
|
146
|
+
|
|
147
|
+
**From 0.5 and earlier (`cli-theme`):** the package was called
|
|
148
|
+
`mmit-cli-theme`, the command `cli-theme` and the folder
|
|
149
|
+
`~/.config/cli-theme/`. Remove the old package once, then install as above:
|
|
150
|
+
|
|
151
|
+
```bash
|
|
152
|
+
pipx uninstall mmit-cli-theme
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
`cli-theme` stays as a second name for `clitheme`, so existing scripts and
|
|
156
|
+
Makefiles keep working. As long as `~/.config/clitheme/` does not exist,
|
|
157
|
+
clitheme reads the theme from the old folder and says so in `show` and in
|
|
158
|
+
`THEME_NOTICE`; `clitheme install` copies your files into the new folder and
|
|
159
|
+
leaves the old one as it is.
|
|
160
|
+
|
|
161
|
+
A Python project adds the package from PyPI to its dependencies. A package
|
|
162
|
+
that is to be published on PyPI itself may only name dependencies from PyPI,
|
|
163
|
+
not a Git address:
|
|
164
|
+
|
|
165
|
+
```toml
|
|
166
|
+
dependencies = [
|
|
167
|
+
"mmit-clitheme>=0.9",
|
|
168
|
+
]
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
[↑ Contents](#contents)
|
|
172
|
+
|
|
173
|
+
## Theme file
|
|
174
|
+
|
|
175
|
+
**Location:** `${XDG_CONFIG_HOME:-~/.config}/clitheme/<name>.theme`.
|
|
176
|
+
`clitheme path` prints the location of the chosen theme.
|
|
177
|
+
|
|
178
|
+
**Choosing a theme:** `clitheme list` shows the templates and your own theme
|
|
179
|
+
files and marks the active one; `clitheme use NAME` switches to it for every
|
|
180
|
+
new process, without touching your shell:
|
|
181
|
+
|
|
182
|
+
```bash
|
|
183
|
+
clitheme list
|
|
184
|
+
clitheme use ocean
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
`use` saves the name in `${XDG_CONFIG_HOME:-~/.config}/clitheme/selected`
|
|
188
|
+
and creates the file of a template that is still missing. The name comes
|
|
189
|
+
from the environment variable `CLI_THEME` first, then from this saved
|
|
190
|
+
choice, else it is `classic`. While `CLI_THEME` is set, `use` still saves
|
|
191
|
+
the choice and says that it takes effect only after `unset CLI_THEME`. A
|
|
192
|
+
name may contain letters, digits, `-` and `_`; an unknown or invalid name
|
|
193
|
+
ends with an error and keeps the previous choice. If the saved choice is
|
|
194
|
+
damaged, `show`, `list` and `THEME_NOTICE` report it and `classic`
|
|
195
|
+
applies.
|
|
196
|
+
|
|
197
|
+
**Format:** one `NAME=value` per line, without quotes and without spaces
|
|
198
|
+
around `=`, so that Make and Bash can include the file directly. Lines
|
|
199
|
+
starting with `#` are comments. A color is a number from 0 to 255, optionally
|
|
200
|
+
prefixed with `bold+` or `dim+`; `bold` or `dim` alone are allowed, and an
|
|
201
|
+
empty value means the terminal color. The file must contain all entries
|
|
202
|
+
except `W_COL`; without it, 12 applies, so older theme files keep working.
|
|
203
|
+
|
|
204
|
+
| Role | Used for | classic |
|
|
205
|
+
|---|---|---|
|
|
206
|
+
| `C_HEAD` | Headings and groups | `bold+11` |
|
|
207
|
+
| `C_KEY` | Labels in the left column: targets, options, keys | `33` |
|
|
208
|
+
| `C_TEXT` | Descriptions in help output | `10` |
|
|
209
|
+
| `C_VAL` | Values, commands, paths | `10` |
|
|
210
|
+
| `C_HINT` | Hints and secondary text | `dim` |
|
|
211
|
+
| `C_ACC` | Emphasis in text: placeholders, allowed values, answers | `14` |
|
|
212
|
+
| `C_OK` | Success (✓), accepted, approved | `10` |
|
|
213
|
+
| `C_WARN` | Warning, stalled, outdated | `208` |
|
|
214
|
+
| `C_ERR` | Error (✗), rejected, conflict | `bold+196` |
|
|
215
|
+
| `C_MARK` | Special status: server, origin of a value | `13` |
|
|
216
|
+
|
|
217
|
+
| Spacing | Meaning | classic |
|
|
218
|
+
|---|---|---|
|
|
219
|
+
| `I_HEAD` | Indent of a group heading | `2` |
|
|
220
|
+
| `I_ROW` | Indent of a row or parameter | `7` |
|
|
221
|
+
| `I_HINT` | Indent of hint text | `7` |
|
|
222
|
+
| `W_KEY` | Width of the label; a longer label gets its own line | `21` |
|
|
223
|
+
| `W_COL` | Grid step: lists (`rows`) widen their first column to a multiple of it when a label is longer than `W_KEY` | `12` |
|
|
224
|
+
| `GAP` | Minimum space between label and text | `2` |
|
|
225
|
+
| `WIDTH` | Maximum line width in a terminal; `0` = full width | `120` |
|
|
226
|
+
| `SPACE` | Blank lines before a group | `1` |
|
|
227
|
+
|
|
228
|
+
**Without a valid file:** if the file is missing, output has no colors and
|
|
229
|
+
uses the spacing of classic. An invalid file is an error that names file,
|
|
230
|
+
line and entry; `clitheme show` reports it, while the output helpers fall
|
|
231
|
+
back to no colors. The theme folder and the file must not be symbolic links;
|
|
232
|
+
CLITheme refuses to read or write through them.
|
|
233
|
+
|
|
234
|
+
[↑ Contents](#contents)
|
|
235
|
+
|
|
236
|
+
## Use
|
|
237
|
+
|
|
238
|
+
**Python:** `Output` writes headings, rows and hints as in the
|
|
239
|
+
[example](#example). For your own output, `load_theme()` returns the theme
|
|
240
|
+
with its colors and spacing, `styles()` the rich style of each role, and
|
|
241
|
+
`rich_style()` converts a single value such as `bold+11` to
|
|
242
|
+
`bold color(11)`. Errors are `ThemeError` with a stable `code` and its
|
|
243
|
+
`params`, so an application can translate them in its own catalog.
|
|
244
|
+
|
|
245
|
+
**Rule for all apps: output ends with one blank line.** `Output.finish()`,
|
|
246
|
+
or the end of a `with Output() as out:` block, writes exactly one blank line
|
|
247
|
+
to each stream that received output (stdout, stderr) and nothing if there
|
|
248
|
+
was none. `ArgumentParser` is a drop-in for `argparse.ArgumentParser` whose
|
|
249
|
+
help (`-h`, `--help`, `print_help()`) and error messages end the same way;
|
|
250
|
+
subparsers inherit it. Machine output such as a path or a command to copy
|
|
251
|
+
goes through `print()` instead of `Output` and stays without the blank line,
|
|
252
|
+
like `clitheme path`.
|
|
253
|
+
|
|
254
|
+
**Lines to copy:** a command or path that is part of the output, in the
|
|
255
|
+
theme's colors, goes through `out.write(Text(...), wrap=False)`. The line is
|
|
256
|
+
never broken, not even when it is wider than the terminal, so it can be
|
|
257
|
+
copied in one piece; with `NO_COLOR` it is plain text. It counts as output,
|
|
258
|
+
so `finish()` closes with the blank line as usual. `out.row(label, value,
|
|
259
|
+
wrap=False)` does the same for the value of a row.
|
|
260
|
+
|
|
261
|
+
**Lists:** `out.rows(entries)` writes several rows of label and value, all
|
|
262
|
+
values in one column. It knows every label beforehand: if one is longer
|
|
263
|
+
than `W_KEY`, the first column including `GAP` becomes the smallest multiple
|
|
264
|
+
of `W_COL` that fits it, so each value stays on its row and lists line up
|
|
265
|
+
with each other. Example: `W_KEY` 21, `W_COL` 12 and a longest label of 31
|
|
266
|
+
characters give a column of 36. If that leaves fewer than 20 characters for
|
|
267
|
+
the value within `WIDTH` or the terminal width, `rows` uses `W_KEY` like
|
|
268
|
+
`row`. A single `row` always uses `W_KEY`.
|
|
269
|
+
|
|
270
|
+
```python
|
|
271
|
+
from cli_theme import ArgumentParser, Output
|
|
272
|
+
|
|
273
|
+
parser = ArgumentParser(prog="app")
|
|
274
|
+
arguments = parser.parse_args()
|
|
275
|
+
with Output() as out:
|
|
276
|
+
out.head("Result")
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
**Help in theme colors:** the help of `ArgumentParser` uses the same layout
|
|
280
|
+
as `Output`. Group headings such as `options:` appear like `head()`, options
|
|
281
|
+
like the label of `row()`, and descriptions start in the same column as a
|
|
282
|
+
value of `row()`. An option shows short and long form as `-i | --info`;
|
|
283
|
+
without a short form its place stays free, so all long forms line up
|
|
284
|
+
(` --restore FILE`). Option names use `C_KEY`, a metavar such as `FILE`
|
|
285
|
+
`C_ACC`, the same layout as BashLib's help for Bash scripts. A label longer
|
|
286
|
+
than `W_KEY` gets its own line. In pipes, with `NO_COLOR` or `TERM=dumb` the
|
|
287
|
+
columns stay and the colors go; argparse's own colors (Python 3.14) are off.
|
|
288
|
+
`add_rows()` adds a section of your own, for example a command list, after
|
|
289
|
+
the argument groups and before the epilog. It needs `HelpFormatter` or a
|
|
290
|
+
subclass as `formatter_class`; with any other formatter `add_rows()` raises
|
|
291
|
+
`TypeError` instead of leaving the section out. The app never reads the
|
|
292
|
+
theme itself; with plain `argparse.ArgumentParser`, pass
|
|
293
|
+
`formatter_class=HelpFormatter`.
|
|
294
|
+
|
|
295
|
+
```python
|
|
296
|
+
from cli_theme import ArgumentParser
|
|
297
|
+
|
|
298
|
+
parser = ArgumentParser(prog="app", description="Build and publish.")
|
|
299
|
+
parser.add_argument("-o", "--output", metavar="FILE", help="write to FILE")
|
|
300
|
+
parser.add_rows("Commands", [("build", "build the package"), ("publish", "upload it")])
|
|
301
|
+
arguments = parser.parse_args()
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
```python
|
|
305
|
+
from cli_theme import load_theme, styles
|
|
306
|
+
|
|
307
|
+
theme = load_theme()
|
|
308
|
+
indent = " " * theme.spacing["i_row"]
|
|
309
|
+
style = styles(theme)["warn"]
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
**Bash and Make:** `clitheme export` reads the chosen theme with the same
|
|
313
|
+
rules as Python and sets `THEME_COLOR_*` (GROUP, TARGET, DESC, VALUE, HINT,
|
|
314
|
+
ACCENT, SUCCESS, WARNING, DANGER, SERVER) as escape sequences,
|
|
315
|
+
`THEME_INDENT_*` (GROUP, TARGET, HINT) as spaces, `THEME_WIDTH_TARGET`,
|
|
316
|
+
`THEME_WIDTH_COLUMN` (`W_COL`), `THEME_COLUMN_GAP`, `THEME_WIDTH_HELP` and `THEME_GROUP_SPACING` as numbers,
|
|
317
|
+
and `THEME_NAME`, `THEME_SOURCE`, `THEME_ORIGIN` and `THEME_NOTICE`. Without
|
|
318
|
+
a valid file the colors stay empty, the spacing is that of classic, and
|
|
319
|
+
`THEME_NOTICE` holds the finding and the next step in two lines; the exit
|
|
320
|
+
code stays 0. The result is cached under `${XDG_CACHE_HOME:-~/.cache}/clitheme/`
|
|
321
|
+
and rebuilt when the theme file, `CLI_THEME`, the choice of `clitheme use`,
|
|
322
|
+
the language or the version of clitheme changes, so the next `eval` or
|
|
323
|
+
`make` shows a new theme at once. `THEME_ORIGIN` is `CLI_THEME`,
|
|
324
|
+
`clitheme use` or `default`.
|
|
325
|
+
|
|
326
|
+
Bash: `--bash` prints quoted assignments; `eval` runs no code from the
|
|
327
|
+
theme file, even with `$(…)` or a backtick in it.
|
|
328
|
+
|
|
329
|
+
```bash
|
|
330
|
+
eval "$(clitheme export --bash)"
|
|
331
|
+
printf '%s%sBuild%s\n' "$THEME_INDENT_GROUP" "$THEME_COLOR_GROUP" $'\e[0m'
|
|
332
|
+
```
|
|
333
|
+
|
|
334
|
+
Make: `--make` prints only the path of a `.mk` file in the cache. Include it
|
|
335
|
+
optionally, so the Makefile still works without clitheme.
|
|
336
|
+
|
|
337
|
+
```makefile
|
|
338
|
+
-include $(shell clitheme export --make 2>/dev/null)
|
|
339
|
+
```
|
|
340
|
+
|
|
341
|
+
Other languages: `--json` prints one JSON object with the same names;
|
|
342
|
+
widths and spacing are numbers, everything else strings. A program starts
|
|
343
|
+
clitheme once and keeps its own fallback, no colors and the spacing of
|
|
344
|
+
classic, for when clitheme is missing, too old for `--json` or not allowed
|
|
345
|
+
to run. In Deno with `deno run --allow-run=clitheme`:
|
|
346
|
+
|
|
347
|
+
```typescript
|
|
348
|
+
const fallback = { THEME_INDENT_GROUP: " ", THEME_COLOR_GROUP: "", THEME_WIDTH_TARGET: 21 };
|
|
349
|
+
let theme: Record<string, string | number> = fallback;
|
|
350
|
+
try {
|
|
351
|
+
const result = await new Deno.Command("clitheme", { args: ["export", "--json"] }).output();
|
|
352
|
+
if (result.success) theme = JSON.parse(new TextDecoder().decode(result.stdout));
|
|
353
|
+
} catch {
|
|
354
|
+
// clitheme is missing or may not run (--allow-run=clitheme)
|
|
355
|
+
}
|
|
356
|
+
console.log(`${theme.THEME_INDENT_GROUP}${theme.THEME_COLOR_GROUP}Build\x1b[0m`);
|
|
357
|
+
```
|
|
358
|
+
|
|
359
|
+
**Deno package `@mmit/clitheme`:** clitheme ships a Deno package with the
|
|
360
|
+
same output: `Theme.load()` reads the theme through `clitheme export --json`
|
|
361
|
+
and has `heading`, `row`, `value`, `status`, `hint` and `help` for a
|
|
362
|
+
`--help` laid out like the one of `changelog` from ProjectTools. Without a
|
|
363
|
+
terminal, with `NO_COLOR` or without a theme file the lines come without
|
|
364
|
+
escape sequences and with the same spacing. `clitheme export --deno` prints
|
|
365
|
+
the path of `mod.ts` in the installed version; an import map points the
|
|
366
|
+
name at it as a file URL, so characters such as `#` or spaces in the path
|
|
367
|
+
stay part of it, without network and without a release:
|
|
368
|
+
|
|
369
|
+
```sh
|
|
370
|
+
deno eval 'import { pathToFileURL } from "node:url";
|
|
371
|
+
const url = pathToFileURL(Deno.args[0]).href;
|
|
372
|
+
console.log(JSON.stringify({ imports: { "@mmit/clitheme": url } }));' \
|
|
373
|
+
"$(clitheme export --deno)" > imports.json
|
|
374
|
+
deno run --allow-run=clitheme --import-map=imports.json app.ts
|
|
375
|
+
```
|
|
376
|
+
|
|
377
|
+
```typescript
|
|
378
|
+
import { Theme } from "@mmit/clitheme";
|
|
379
|
+
|
|
380
|
+
const theme = Theme.load();
|
|
381
|
+
console.log(theme.help({
|
|
382
|
+
usage: "app [-o OUTPUT] [-h]",
|
|
383
|
+
sections: [{
|
|
384
|
+
title: "Options",
|
|
385
|
+
items: [
|
|
386
|
+
{ names: ["-o", "--output"], metavar: "OUTPUT", help: "Output file." },
|
|
387
|
+
{ names: ["-h", "--help"], help: "Show this help and exit." },
|
|
388
|
+
],
|
|
389
|
+
}],
|
|
390
|
+
}));
|
|
391
|
+
```
|
|
392
|
+
|
|
393
|
+
**Bash library `cli.lib.sh`:** clitheme ships the theme output for Bash
|
|
394
|
+
scripts, the functions known from `cli.lib.sh` in BashLib, but without
|
|
395
|
+
BashLib: `printThemeHeading`, `printThemeRow`, `printThemeValue`,
|
|
396
|
+
`printThemeOption`, `printThemeExample`, `printThemeHint`, `printThemeStatus`,
|
|
397
|
+
`usageLine` and the building blocks `themeStyle`, `themeAccent` and
|
|
398
|
+
`themeMark`. Text is printed literally: paths with backslashes, `$(…)` and
|
|
399
|
+
control sequences in a value appear as they are, without escaping them
|
|
400
|
+
first. Only color sequences written as text (`\x1B[…m`, `\033[…m`,
|
|
401
|
+
`\e[…m`) take effect, such as those from `themeAccent` or a palette like
|
|
402
|
+
`${YELLOW}…${NC}`. Real control characters in a value, such as the
|
|
403
|
+
sequences that set the window title or clear the screen, are replaced by
|
|
404
|
+
`�`; line break and tab stay. The Python library and the Deno package do
|
|
405
|
+
the same. `themeEscape` is deprecated and returns its text
|
|
406
|
+
unchanged; BashLib's `showMenu` is not included. It needs Bash 5. Without a terminal, with
|
|
407
|
+
`NO_COLOR` or `TERM=dumb` the lines come without escape sequences; without
|
|
408
|
+
clitheme without colors and with the spacing of classic. `clilib-path`
|
|
409
|
+
prints the folder of `cli.lib.sh`, in a clone, an installed and an editable
|
|
410
|
+
clitheme alike, as plain Bash without Python. If BashLib's `cli.lib.sh` is
|
|
411
|
+
already loaded, this one steps back; BashLib's `tools.lib.sh` loaded later
|
|
412
|
+
still brings its own palette.
|
|
413
|
+
|
|
414
|
+
```bash
|
|
415
|
+
CLI_LIBS="${CLI_LIBS:-$(clilib-path)}"
|
|
416
|
+
if [[ "${__CLITHEME_CLI_LIB__:=""}" == "" ]]; then . "${CLI_LIBS}/cli.lib.sh"; fi
|
|
417
|
+
|
|
418
|
+
printThemeHeading "Options"
|
|
419
|
+
printThemeOption -o --output FILE "Output file"
|
|
420
|
+
printThemeStatus ✓ "Report written" OK
|
|
421
|
+
```
|
|
422
|
+
|
|
423
|
+
**Makefile help:** `make.lib.sh`, next to `cli.lib.sh`, has
|
|
424
|
+
`showMakeTargets PROJECT FILE…` for `make help`, without BashLib. It prints
|
|
425
|
+
a head with the usage line and the project (such as name and version),
|
|
426
|
+
then the groups
|
|
427
|
+
(`##@ Group`) and targets (`target: ## description`, `##R` and `##D` for
|
|
428
|
+
server targets) from the Makefiles; descriptions appear as they are. The
|
|
429
|
+
head is English by default and German with a German locale (`LANGUAGE`,
|
|
430
|
+
`LC_ALL`, `LC_MESSAGES`, `LANG`, else the system language); its texts sit in
|
|
431
|
+
the array `MAKE_TEXTS`, so another language is two more entries. `make info` and
|
|
432
|
+
`make hints` use
|
|
433
|
+
`printThemeHeading` and `printThemeValue`. `BASH_ENV` loads the library
|
|
434
|
+
into every recipe line:
|
|
435
|
+
|
|
436
|
+
```makefile
|
|
437
|
+
SHELL := bash
|
|
438
|
+
export PROJECT_NAME := $(notdir $(CURDIR))
|
|
439
|
+
export CLI_LIBS := $(shell clilib-path)
|
|
440
|
+
export HELP_FILES = $(value MAKEFILE_LIST)
|
|
441
|
+
help info hints: export BASH_ENV := $${CLI_LIBS}/make.lib.sh
|
|
442
|
+
|
|
443
|
+
help: ## Show this help
|
|
444
|
+
@showMakeTargets "$${PROJECT_NAME}" $${HELP_FILES}
|
|
445
|
+
```
|
|
446
|
+
|
|
447
|
+
**Examples:** [examples](https://github.com/MikeMitterer/python-clitheme/blob/master/examples/README.md) holds a small, runnable report
|
|
448
|
+
for Bash, Make, TypeScript (Node.js), Deno and Python.
|
|
449
|
+
|
|
450
|
+
[↑ Contents](#contents)
|
|
451
|
+
|
|
452
|
+
## Development
|
|
453
|
+
|
|
454
|
+
Setting up from the checkout, tests and translations are described in the
|
|
455
|
+
[developer documentation](https://github.com/MikeMitterer/python-clitheme/blob/master/docs/development.md) (German).
|
|
456
|
+
|
|
457
|
+
[↑ Contents](#contents)
|
|
458
|
+
|
|
459
|
+
## License
|
|
460
|
+
|
|
461
|
+
Copyright © 2026 Michael Mitterer. **MangoLila GmbH** is the provider and
|
|
462
|
+
licensor.
|
|
463
|
+
|
|
464
|
+
CLITheme is licensed under the **[EUPL 1.2](https://github.com/MikeMitterer/python-clitheme/blob/master/LICENSE)**, version 1.2 only.
|
|
465
|
+
It permits personal and commercial use, changes, redistribution, sale and
|
|
466
|
+
hosting without a paid license.
|
|
467
|
+
|
|
468
|
+
If you redistribute CLITheme or a changed version, or offer it as a network
|
|
469
|
+
service, keep the copyright and license notices, mark your changes and
|
|
470
|
+
provide the corresponding source under the license's copyleft rules.
|
|
471
|
+
|
|
472
|
+
The warranty and liability exclusions in EUPL Articles 7 and 8 also apply to
|
|
473
|
+
consumers, as far as the law permits. Mandatory rights remain unaffected,
|
|
474
|
+
including liability for intent, gross negligence, personal injury and product
|
|
475
|
+
liability. No additional guarantee is given.
|
|
476
|
+
|
|
477
|
+
Contact: **office@MangoLila.at**.
|
|
478
|
+
|
|
479
|
+
Details: [LICENSE](https://github.com/MikeMitterer/python-clitheme/blob/master/LICENSE) · [German license text](https://github.com/MikeMitterer/python-clitheme/blob/master/LICENSE.de.txt) ·
|
|
480
|
+
[Provider and consumer declaration](https://github.com/MikeMitterer/python-clitheme/blob/master/LICENSING.md)
|
|
481
|
+
|
|
482
|
+
[↑ Contents](#contents)
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
cli_theme/__init__.py,sha256=a3U-pBBas122VPIVEloOoyOPgaoXk_nJ545mMPqZa4I,988
|
|
2
|
+
cli_theme/arguments.py,sha256=wF0vV2aJ8GydG_awn7lTrPs5q0nUZnLWk_AMk5R3iGY,12611
|
|
3
|
+
cli_theme/cli.py,sha256=5n7nysmSoigWlszmrlHVJNUUemE5mtEwLtIqJ_pht-o,10468
|
|
4
|
+
cli_theme/export.py,sha256=kJDfYj5vU3uhLTE49pWhA2hKumjZ032aFK4xv3eHW2o,8738
|
|
5
|
+
cli_theme/i18n.py,sha256=WnV7lVl6A6vjrDls6X2hFdZQP3Yvf1vIHVgi_Jwa9k4,704
|
|
6
|
+
cli_theme/output.py,sha256=hvWI5XaGQGggV7Ebp-VTwIdCR6sSRGt8r1C6qN_yYtQ,11093
|
|
7
|
+
cli_theme/skill.py,sha256=Wj9OczVBB219GGVMadwKOcvP51oOGYPKLGUc_qs-Kx0,5094
|
|
8
|
+
cli_theme/theme.py,sha256=33wh-JG_5LdQQ55vOsRuv1Cbrn5cLSlTLQJ8uWalFuY,16540
|
|
9
|
+
cli_theme/bash/cli.lib.sh,sha256=I1yS2h6jT9h9Ko5SQztbSdhh7BBkSxy_RDNuORa1ZA0,20642
|
|
10
|
+
cli_theme/bash/make.lib.sh,sha256=P_fnBDaAo5s_FD021hs3KLrkL3M-I30iT9ldsVG6Yxc,6479
|
|
11
|
+
cli_theme/deno/deno.json,sha256=6j_5n9Ej2VaWg8tlDDDbxpbx7nCWQmlHnZmlzHz1a0c,182
|
|
12
|
+
cli_theme/deno/help.ts,sha256=NvCop3Drj3EiRfWWg7fO9ffnzOaQaYhM4-A_EcfV4dE,6541
|
|
13
|
+
cli_theme/deno/mod.ts,sha256=4BHWD-C5-nH7oV_clBEV4p9A2XorZDq_wVVpR_G7iDM,15862
|
|
14
|
+
cli_theme/locales/de/LC_MESSAGES/cli_theme.mo,sha256=oCxgvT4xnVxFSlMS2rocOEYh6fIJk-ihUkmtA7J68sM,10338
|
|
15
|
+
cli_theme/locales/de/LC_MESSAGES/cli_theme.po,sha256=XdIhFwJNqL-Rbln-OMgbikvuR1n2Vx-2UY25sKcVnLY,10924
|
|
16
|
+
cli_theme/templates/classic.theme,sha256=KWyqEUyZktnl0uXeFYo0n7i0t4mp5yrLtREWXdVRduY,1585
|
|
17
|
+
cli_theme/templates/earth.theme,sha256=UArq5SHmSv0aXZ9-1jfNQ1ZZUrY6rz4VhSrjJACM9X4,1576
|
|
18
|
+
cli_theme/templates/forest.theme,sha256=xQCRzSwOFHozQdipoa-6XAh71zBzlcJJ4fdobqoaaDs,1562
|
|
19
|
+
cli_theme/templates/mono.theme,sha256=JXQQ4iiGLTisAiSLCOzA4kkOU5VQzIGRvMWZHdaDE8M,1600
|
|
20
|
+
cli_theme/templates/neon.theme,sha256=rCIkk9IoAERsRxzY3tP-AWTJJFonDYxcV-l_sUFkuDE,1567
|
|
21
|
+
cli_theme/templates/night.theme,sha256=4yA6R9YVPTcTxrhLOLNgu7XNwJkjg7RxUnuztrNdw_E,1582
|
|
22
|
+
cli_theme/templates/ocean.theme,sha256=4bsmQfFFQHXQzWB3lOnev0k55NbkAGbt3sB5-QWfsuo,1577
|
|
23
|
+
cli_theme/templates/shell.theme,sha256=JGwaUAhQPrqeq7oW1LaCqER79Eh7oy2-_8Jz2nWMQ5M,1593
|
|
24
|
+
cli_theme/templates/sunset.theme,sha256=RvzYirq3SLg5ClbRNv8HXV9-tMNU4TkwsmSeGAzjkFM,1586
|
|
25
|
+
mmit_clitheme-0.15.0.data/scripts/clilib-path,sha256=YA9SoDNTutvZW58ZmpTJaTC_G2Fe7AibPIJOU9m-RhY,3051
|
|
26
|
+
mmit_clitheme-0.15.0.dist-info/licenses/LICENSE,sha256=b8nnCcy_4Nd_v_okJ6mDKCvi64jkexzbSfIag7TR5mU,13827
|
|
27
|
+
mmit_clitheme-0.15.0.dist-info/licenses/LICENSE.de.txt,sha256=IIcFvrbfbEGLgh9zss8ZLZ1caDehpZORomHHq-L7Dc4,15282
|
|
28
|
+
mmit_clitheme-0.15.0.dist-info/licenses/LICENSING.md,sha256=MFSKAl1sunI0kcQ-DVkH-RKjLW6yVSMT-M3VdUYn4_w,4785
|
|
29
|
+
mmit_clitheme-0.15.0.dist-info/METADATA,sha256=cDyepIhRrWaw7noO-zYcxnOdx31SWPtEKvnuycNV4y8,21119
|
|
30
|
+
mmit_clitheme-0.15.0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
|
|
31
|
+
mmit_clitheme-0.15.0.dist-info/entry_points.txt,sha256=4Xd88sWiJDJ34d4x6RZ9kqAllLXpftb77k4bMsbe5bA,79
|
|
32
|
+
mmit_clitheme-0.15.0.dist-info/top_level.txt,sha256=rBycGI8glGID2BOMenTCFV3mSIO4HffJcySkp600SJg,10
|
|
33
|
+
mmit_clitheme-0.15.0.dist-info/RECORD,,
|