devstuff 2.9.0__py3-none-any.whl → 2.11.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.
- dev_setup/cli.py +2 -0
- dev_setup/commands/help_cmd.py +1 -0
- dev_setup/commands/outdated_cmd.py +141 -0
- dev_setup/commands/update_cmd.py +2 -20
- dev_setup/configure/starship/icons.py +166 -0
- dev_setup/configure/starship/model.py +22 -2
- dev_setup/configure/starship/render.py +39 -24
- dev_setup/configure/starship/wizard.py +309 -0
- dev_setup/generic.py +107 -20
- dev_setup/ui.py +9 -0
- dev_setup/updates.py +148 -0
- {devstuff-2.9.0.dist-info → devstuff-2.11.0.dist-info}/METADATA +59 -1
- {devstuff-2.9.0.dist-info → devstuff-2.11.0.dist-info}/RECORD +15 -12
- {devstuff-2.9.0.dist-info → devstuff-2.11.0.dist-info}/WHEEL +0 -0
- {devstuff-2.9.0.dist-info → devstuff-2.11.0.dist-info}/entry_points.txt +0 -0
dev_setup/cli.py
CHANGED
|
@@ -33,6 +33,7 @@ def _register_commands() -> None:
|
|
|
33
33
|
from dev_setup.commands.install_cmd import install_cmd
|
|
34
34
|
from dev_setup.commands.links_cmd import links_cmd
|
|
35
35
|
from dev_setup.commands.list_cmd import list_cmd
|
|
36
|
+
from dev_setup.commands.outdated_cmd import outdated_cmd
|
|
36
37
|
from dev_setup.commands.remove_cmd import remove_cmd
|
|
37
38
|
from dev_setup.commands.run_cmd import run_cmd
|
|
38
39
|
from dev_setup.commands.skills_cmd import skills_cmd
|
|
@@ -44,6 +45,7 @@ def _register_commands() -> None:
|
|
|
44
45
|
cli.add_command(remove_cmd, "uninstall")
|
|
45
46
|
cli.add_command(doctor_cmd, "doctor")
|
|
46
47
|
cli.add_command(update_cmd, "update")
|
|
48
|
+
cli.add_command(outdated_cmd, "outdated")
|
|
47
49
|
cli.add_command(configure_cmd, "configure")
|
|
48
50
|
cli.add_command(configure_cmd, "config")
|
|
49
51
|
cli.add_command(add_cmd, "add")
|
dev_setup/commands/help_cmd.py
CHANGED
|
@@ -25,6 +25,7 @@ def print_help() -> None:
|
|
|
25
25
|
("install", "[package ...]", "Install packages (interactive if no args)"),
|
|
26
26
|
("remove", "<package ...>", "Uninstall installed packages"),
|
|
27
27
|
("update", "[package ...] [--version]", "Update packages (interactive if no args)"),
|
|
28
|
+
("outdated", "[package ...] [--json]", "Show which installed packages have updates"),
|
|
28
29
|
("configure", "[tool] [--list] [--path]", "Set up a tool with a guided wizard"),
|
|
29
30
|
("add", "", "Add a custom package (guided wizard)"),
|
|
30
31
|
("delete", "<key>", "Remove a custom package from the registry"),
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import json
|
|
4
|
+
import sys
|
|
5
|
+
from contextlib import nullcontext
|
|
6
|
+
|
|
7
|
+
import click
|
|
8
|
+
from rich.markup import escape
|
|
9
|
+
|
|
10
|
+
from dev_setup import registry, ui, verbose
|
|
11
|
+
from dev_setup.base import Tool
|
|
12
|
+
from dev_setup.updates import Row, State, collect_candidates, make_row, sort_rows, summarize
|
|
13
|
+
|
|
14
|
+
# One glyph + wording per state. `unknown` and `unsupported` deliberately share nothing
|
|
15
|
+
# with `current`: "could not check" must never read as "up to date" (spec FR-7).
|
|
16
|
+
_STATUS: dict[State, tuple[str, str]] = {
|
|
17
|
+
State.OUTDATED: (ui.AMBER, "⬆ outdated"),
|
|
18
|
+
State.CURRENT: (ui.GREEN, "✔ current"),
|
|
19
|
+
State.UNKNOWN: (ui.GRAY, "? unknown"),
|
|
20
|
+
State.UNSUPPORTED: (ui.GRAY, "– can't check"),
|
|
21
|
+
State.NOT_INSTALLED: (ui.GRAY, "○ not installed"),
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
# Order of the closing summary line; the wording is each state's own name.
|
|
25
|
+
_SUMMARY_ORDER = (
|
|
26
|
+
State.OUTDATED, State.CURRENT, State.UNKNOWN, State.UNSUPPORTED, State.NOT_INSTALLED,
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
_FOOTER_NAMES = 12
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
@click.command("outdated")
|
|
33
|
+
@click.option(
|
|
34
|
+
"--updates-only", is_flag=True,
|
|
35
|
+
help="Show only tools with an update available (the summary still counts everything).",
|
|
36
|
+
)
|
|
37
|
+
@click.option(
|
|
38
|
+
"--all", "show_all", is_flag=True,
|
|
39
|
+
help="List the tools that can't be checked (bash/script installers) instead of one footer line.",
|
|
40
|
+
)
|
|
41
|
+
@click.option(
|
|
42
|
+
"--json", "as_json", is_flag=True,
|
|
43
|
+
help="Write a JSON array to stdout and nothing else. Includes every state.",
|
|
44
|
+
)
|
|
45
|
+
@click.argument("packages", nargs=-1)
|
|
46
|
+
def outdated_cmd(packages: tuple[str, ...], updates_only: bool, show_all: bool, as_json: bool) -> None:
|
|
47
|
+
"""Show which installed packages have a newer version available.
|
|
48
|
+
|
|
49
|
+
Read-only: nothing is installed, updated or written. Each package is reported as
|
|
50
|
+
outdated, current, unknown (a check exists but couldn't answer), or unsupported
|
|
51
|
+
(script/bash installers have no way to check). Unknown and unsupported are never
|
|
52
|
+
reported as current. Use `devstuff update` to act on the result.
|
|
53
|
+
|
|
54
|
+
The exit status says whether the lookup ran, not what it found: 0 even when
|
|
55
|
+
updates are available.
|
|
56
|
+
"""
|
|
57
|
+
named: list[Tool] | None = None
|
|
58
|
+
if packages:
|
|
59
|
+
named = []
|
|
60
|
+
for key in packages:
|
|
61
|
+
tool = registry.get(key)
|
|
62
|
+
if tool is None:
|
|
63
|
+
click.echo(f"Unknown package: '{key}'", err=True)
|
|
64
|
+
sys.exit(1)
|
|
65
|
+
named.append(tool)
|
|
66
|
+
|
|
67
|
+
interactive = sys.stdout.isatty() and not as_json
|
|
68
|
+
if interactive:
|
|
69
|
+
ui.print_banner()
|
|
70
|
+
progress = (
|
|
71
|
+
verbose.step("Checking installed packages for updates...") if interactive else nullcontext()
|
|
72
|
+
)
|
|
73
|
+
with progress:
|
|
74
|
+
candidates = collect_candidates(named)
|
|
75
|
+
|
|
76
|
+
result = [make_row(tool, status) for tool, status in candidates]
|
|
77
|
+
if named is not None:
|
|
78
|
+
found = {tool.key for tool, _ in candidates}
|
|
79
|
+
result += [make_row(t, None, installed=False) for t in named if t.key not in found]
|
|
80
|
+
|
|
81
|
+
result = sort_rows(result)
|
|
82
|
+
shown = [r for r in result if r.state is State.OUTDATED] if updates_only else result
|
|
83
|
+
|
|
84
|
+
if as_json:
|
|
85
|
+
click.echo(json.dumps([r.to_json() for r in shown], indent=2))
|
|
86
|
+
return
|
|
87
|
+
|
|
88
|
+
_render(shown, result, updates_only=updates_only, show_all=show_all)
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
def _render(shown: list[Row], everything: list[Row], *, updates_only: bool, show_all: bool) -> None:
|
|
92
|
+
if not everything:
|
|
93
|
+
ui.info("No installed packages to check.")
|
|
94
|
+
return
|
|
95
|
+
|
|
96
|
+
collapsed = [] if show_all else [r for r in shown if r.state is State.UNSUPPORTED]
|
|
97
|
+
rows = [r for r in shown if r not in collapsed]
|
|
98
|
+
|
|
99
|
+
if rows:
|
|
100
|
+
tbl = ui.table()
|
|
101
|
+
tbl.add_column("Package", style="bold", no_wrap=True)
|
|
102
|
+
tbl.add_column("Type", style=ui.CYAN, no_wrap=True)
|
|
103
|
+
tbl.add_column("Installed", style=ui.GRAY, no_wrap=True)
|
|
104
|
+
tbl.add_column("Latest", style=ui.GRAY, no_wrap=True)
|
|
105
|
+
tbl.add_column("Status")
|
|
106
|
+
for r in rows:
|
|
107
|
+
tbl.add_row(r.key, r.type, r.installed or "", r.latest or "", _status_cell(r))
|
|
108
|
+
ui.console.print(tbl)
|
|
109
|
+
elif updates_only:
|
|
110
|
+
ui.info("No updates available.")
|
|
111
|
+
|
|
112
|
+
if collapsed:
|
|
113
|
+
_footer(collapsed)
|
|
114
|
+
|
|
115
|
+
ui.dim(_summary(everything))
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
def _status_cell(r: Row) -> str:
|
|
119
|
+
color, label = _STATUS[r.state]
|
|
120
|
+
cell = f"[{color}]{label}[/]"
|
|
121
|
+
if r.note:
|
|
122
|
+
# Escaped: a note is free text from a checker, and Rich would read "[docs]" as markup.
|
|
123
|
+
cell += f"\n[{ui.GRAY}]{escape(r.note)}[/]"
|
|
124
|
+
return cell
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
def _footer(unsupported: list[Row]) -> None:
|
|
128
|
+
kinds = ", ".join(sorted({r.type for r in unsupported}))
|
|
129
|
+
names = [r.key for r in unsupported]
|
|
130
|
+
listed = ", ".join(names[:_FOOTER_NAMES])
|
|
131
|
+
if len(names) > _FOOTER_NAMES:
|
|
132
|
+
listed += f", +{len(names) - _FOOTER_NAMES} more (--all lists them)"
|
|
133
|
+
noun = "tool" if len(names) == 1 else "tools"
|
|
134
|
+
ui.dim(f"{len(names)} {noun} can't be checked ({kinds} installers): {listed}")
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
def _summary(rows: list[Row]) -> str:
|
|
138
|
+
counts = summarize(rows)
|
|
139
|
+
return " · ".join(
|
|
140
|
+
f"{counts[s]} {s.value.replace('-', ' ')}" for s in _SUMMARY_ORDER if counts[s]
|
|
141
|
+
)
|
dev_setup/commands/update_cmd.py
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
3
|
import sys
|
|
4
|
-
from concurrent.futures import ThreadPoolExecutor
|
|
5
4
|
|
|
6
5
|
import click
|
|
7
6
|
import questionary
|
|
8
7
|
|
|
9
8
|
from dev_setup import registry, ui
|
|
10
9
|
from dev_setup.base import Tool
|
|
11
|
-
from dev_setup.
|
|
10
|
+
from dev_setup.updates import collect_candidates
|
|
12
11
|
|
|
13
12
|
|
|
14
13
|
@click.command("update")
|
|
@@ -74,28 +73,11 @@ def _update_one(tool: Tool, version: str | None) -> bool:
|
|
|
74
73
|
return False
|
|
75
74
|
|
|
76
75
|
|
|
77
|
-
def _collect_update_candidates() -> list[tuple[Tool, UpdateStatus]]:
|
|
78
|
-
"""Return (tool, UpdateStatus) for every installed tool, probed concurrently.
|
|
79
|
-
|
|
80
|
-
Pure data-gathering, kept free of any UI/prompt code so it can be exercised
|
|
81
|
-
directly without a terminal.
|
|
82
|
-
"""
|
|
83
|
-
tools = registry.all_tools()
|
|
84
|
-
with ThreadPoolExecutor(max_workers=8) as pool:
|
|
85
|
-
installed_flags = list(pool.map(lambda t: t.is_installed(), tools))
|
|
86
|
-
installed = [t for t, flag in zip(tools, installed_flags, strict=True) if flag]
|
|
87
|
-
if not installed:
|
|
88
|
-
return []
|
|
89
|
-
with ThreadPoolExecutor(max_workers=8) as pool:
|
|
90
|
-
statuses = list(pool.map(lambda t: t.check_for_update(), installed)) # type: ignore[attr-defined]
|
|
91
|
-
return list(zip(installed, statuses, strict=True))
|
|
92
|
-
|
|
93
|
-
|
|
94
76
|
def _update_interactive() -> None:
|
|
95
77
|
ui.print_banner()
|
|
96
78
|
|
|
97
79
|
with ui.spinner("Checking installed packages for available updates..."):
|
|
98
|
-
candidates =
|
|
80
|
+
candidates = collect_candidates()
|
|
99
81
|
|
|
100
82
|
if not candidates:
|
|
101
83
|
ui.info("No installed packages to update.")
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
"""A curated catalog of Nerd Font glyphs and emoji for the icon picker.
|
|
2
|
+
|
|
3
|
+
Every entry has a stable ``key``, a human-readable ``label`` (what the filterable
|
|
4
|
+
picker searches against), the ``glyph`` string that gets emitted into the config,
|
|
5
|
+
and one or more ``categories`` so the picker can group them. Glyphs are written as
|
|
6
|
+
escapes with their Nerd Font names so the source stays reviewable without the font
|
|
7
|
+
installed — the same convention as ``model.py``'s section icons.
|
|
8
|
+
|
|
9
|
+
The catalog is deliberately not exhaustive: it covers the domains the wizard's
|
|
10
|
+
sections live in (languages, cloud, git, shell, general) with a handful of
|
|
11
|
+
alternatives each, plus a set of generic shapes that work for anything. A user
|
|
12
|
+
who wants a glyph not listed here can type one into the picker's free-text input.
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
from __future__ import annotations
|
|
16
|
+
|
|
17
|
+
from dataclasses import dataclass
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
@dataclass(frozen=True)
|
|
21
|
+
class Icon:
|
|
22
|
+
key: str
|
|
23
|
+
label: str
|
|
24
|
+
glyph: str
|
|
25
|
+
categories: tuple[str, ...] = ()
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
# Category constants — keep in sync with the wizard's grouping.
|
|
29
|
+
CAT_LANG = "Languages"
|
|
30
|
+
CAT_CLOUD = "Cloud & Infrastructure"
|
|
31
|
+
CAT_GIT = "Git"
|
|
32
|
+
CAT_SHELL = "Shell"
|
|
33
|
+
CAT_GENERAL = "General"
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
ICONS: tuple[Icon, ...] = (
|
|
37
|
+
# -- General -----------------------------------------------------------------
|
|
38
|
+
Icon("folder", "Folder", "\uf07b ", (CAT_GENERAL,)), # nf-fa-folder
|
|
39
|
+
Icon("folder_open", "Open folder", "\uf07c ", (CAT_GENERAL,)), # nf-fa-folder_open
|
|
40
|
+
Icon("package", "Package", "\U000f03d7 ", (CAT_GENERAL,)), # nf-md-package_variant_closed
|
|
41
|
+
Icon("package_box", "Package box", "\uf1b6 ", (CAT_GENERAL,)), # nf-fa-inbox
|
|
42
|
+
Icon("container", "Container", "\U000f021b ", (CAT_GENERAL,)), # nf-md-container
|
|
43
|
+
Icon("cube", "Cube", "\uf1b2 ", (CAT_GENERAL,)), # nf-fa-cube
|
|
44
|
+
Icon("gear", "Gear", "\uf013 ", (CAT_GENERAL,)), # nf-fa-cog
|
|
45
|
+
Icon("wrench", "Wrench", "\uf0ad ", (CAT_GENERAL,)), # nf-fa-wrench
|
|
46
|
+
Icon("rocket", "Rocket", "\uf135 ", (CAT_GENERAL,)), # nf-fa-rocket
|
|
47
|
+
Icon("star", "Star", "\uf005 ", (CAT_GENERAL,)), # nf-fa-star
|
|
48
|
+
Icon("heart", "Heart", "\uf004 ", (CAT_GENERAL,)), # nf-fa-heart
|
|
49
|
+
Icon("check", "Check mark", "\uf00c ", (CAT_GENERAL,)), # nf-fa-check
|
|
50
|
+
Icon("x", "X mark", "\uf00d ", (CAT_GENERAL,)), # nf-fa-times
|
|
51
|
+
Icon("lightbulb", "Light bulb", "\uf0eb ", (CAT_GENERAL,)), # nf-fa-lightbulb_o
|
|
52
|
+
Icon("fire", "Fire", "\uf06d ", (CAT_GENERAL,)), # nf-fa-fire
|
|
53
|
+
Icon("bolt", "Lightning bolt", "\uf0e7 ", (CAT_GENERAL,)), # nf-fa-bolt
|
|
54
|
+
Icon("terminal", "Terminal", "\uf120 ", (CAT_GENERAL,)), # nf-fa-terminal
|
|
55
|
+
Icon("keyboard", "Keyboard", "\uf11c ", (CAT_GENERAL,)), # nf-fa-keyboard_o
|
|
56
|
+
Icon("clock", "Clock", "\uf017 ", (CAT_GENERAL,)), # nf-fa-clock_o
|
|
57
|
+
Icon("hourglass", "Hourglass", "\uf252 ", (CAT_GENERAL,)), # nf-fa-hourglass_half
|
|
58
|
+
Icon("chart", "Bar chart", "\uf080 ", (CAT_GENERAL,)), # nf-fa-bar_chart
|
|
59
|
+
Icon("database", "Database", "\uf1c0 ", (CAT_GENERAL,)), # nf-fa-database
|
|
60
|
+
Icon("server", "Server", "\uf233 ", (CAT_GENERAL,)), # nf-fa-server
|
|
61
|
+
Icon("globe", "Globe", "\uf0ac ", (CAT_GENERAL,)), # nf-fa-globe
|
|
62
|
+
Icon("link", "Link", "\uf0c1 ", (CAT_GENERAL,)), # nf-fa-link
|
|
63
|
+
|
|
64
|
+
# -- Git ---------------------------------------------------------------------
|
|
65
|
+
Icon("git_branch", "Git branch", "\ue0a0 ", (CAT_GIT,)), # nf-pl-branch
|
|
66
|
+
Icon("git_branch_alt", "Git branch (alt)", "\uf126 ", (CAT_GIT,)), # nf-fa-code_fork
|
|
67
|
+
Icon("git_commit", "Git commit", "\ue0a1 ", (CAT_GIT,)), # nf-pl-narrow
|
|
68
|
+
Icon("git_merge", "Git merge", "\ue0a3 ", (CAT_GIT,)), # nf-pl-branch
|
|
69
|
+
Icon("git_pull", "Git pull request", "\uf09b ", (CAT_GIT,)), # nf-fa-github_alt
|
|
70
|
+
Icon("fork", "Fork", "\uf126 ", (CAT_GIT,)), # nf-fa-code_fork
|
|
71
|
+
Icon("diff", "Diff", "\ue728 ", (CAT_GIT,)), # nf-seti-git
|
|
72
|
+
|
|
73
|
+
# -- Languages ---------------------------------------------------------------
|
|
74
|
+
Icon("nodejs_small", "Node.js small", "\ue718 ", (CAT_LANG,)), # nf-dev-nodejs_small
|
|
75
|
+
Icon("nodejs", "Node.js", "\ue74e ", (CAT_LANG,)), # nf-dev-nodejs_large
|
|
76
|
+
Icon("js", "JavaScript", "\ue74e ", (CAT_LANG,)),
|
|
77
|
+
Icon("js_square", "JavaScript (square)", "\ue781 ", (CAT_LANG,)), # nf-dev-javascript
|
|
78
|
+
Icon("typescript", "TypeScript", "\ue628 ", (CAT_LANG,)), # nf-seti-file_type_ts
|
|
79
|
+
Icon("deno", "Deno", "\ue70c ", (CAT_LANG,)), # nf-seti-file_type_deno
|
|
80
|
+
Icon("deno_robot", "Deno (robot)", "\U000f06a9 ", (CAT_LANG,)), # nf-md-robot
|
|
81
|
+
Icon("bun", "Bun (croissant)", "\U000f07f0 ", (CAT_LANG,)), # nf-md-food_croissant
|
|
82
|
+
Icon("python", "Python", "\ue73c ", (CAT_LANG,)), # nf-dev-python
|
|
83
|
+
Icon("python_alt", "Python (alt)", "\ue235 ", (CAT_LANG,)), # nf-fa-python
|
|
84
|
+
Icon("rust", "Rust", "\ue7a8 ", (CAT_LANG,)), # nf-dev-rust
|
|
85
|
+
Icon("rust_crab", "Rust (crab)", "\U000f0f80 ", (CAT_LANG,)), # nf-md-crab
|
|
86
|
+
Icon("go", "Go", "\ue627 ", (CAT_LANG,)), # nf-seti-go
|
|
87
|
+
Icon("go_gopher", "Go (gopher)", "\ue626 ", (CAT_LANG,)), # nf-seti-go
|
|
88
|
+
Icon("java", "Java", "\ue256 ", (CAT_LANG,)), # nf-dev-java
|
|
89
|
+
Icon("java_cup", "Java (cup)", "\uf266 ", (CAT_LANG,)), # nf-fa-java
|
|
90
|
+
Icon("php", "PHP", "\ue73d ", (CAT_LANG,)), # nf-dev-php
|
|
91
|
+
Icon("php_elephant", "PHP (elephant)", "\ue608 ", (CAT_LANG,)), # nf-seti-php
|
|
92
|
+
Icon("ruby", "Ruby", "\ue791 ", (CAT_LANG,)), # nf-dev-ruby
|
|
93
|
+
Icon("ruby_gem", "Ruby (gem)", "\uf219 ", (CAT_LANG,)), # nf-fa-ruby
|
|
94
|
+
Icon("elixir", "Elixir (droplet)", "\U000f078b ", (CAT_LANG,)), # nf-md-droplet
|
|
95
|
+
Icon("elixir_alt", "Elixir", "\ue62d ", (CAT_LANG,)), # nf-seti-elixir
|
|
96
|
+
Icon("dotnet", ".NET", "\U000f071e ", (CAT_LANG,)), # nf-md-microsoft_dot_net
|
|
97
|
+
Icon("csharp", "C#", "\U000f031b ", (CAT_LANG,)), # nf-md-language_csharp
|
|
98
|
+
Icon("cpp", "C++", "\U000f061b ", (CAT_LANG,)), # nf-md-language_cpp
|
|
99
|
+
Icon("c", "C", "\U000f061c ", (CAT_LANG,)), # nf-md-language_c
|
|
100
|
+
Icon("swift", "Swift", "\ue755 ", (CAT_LANG,)), # nf-dev-swift
|
|
101
|
+
Icon("kotlin", "Kotlin", "\ue634 ", (CAT_LANG,)), # nf-seti-file_type_kotlin
|
|
102
|
+
Icon("scala", "Scala", "\ue737 ", (CAT_LANG,)), # nf-dev-scala
|
|
103
|
+
Icon("haskell", "Haskell", "\ue77f ", (CAT_LANG,)), # nf-dev-haskell
|
|
104
|
+
Icon("lua", "Lua", "\ue620 ", (CAT_LANG,)), # nf-seti-file_type_lua
|
|
105
|
+
Icon("perl", "Perl", "\ue769 ", (CAT_LANG,)), # nf-dev-perl
|
|
106
|
+
Icon("clojure", "Clojure", "\ue76a ", (CAT_LANG,)), # nf-dev-clojure
|
|
107
|
+
Icon("zig", "Zig", "\U000f071f ", (CAT_LANG,)), # nf-md-language_zig
|
|
108
|
+
|
|
109
|
+
# -- Cloud & Infrastructure --------------------------------------------------
|
|
110
|
+
Icon("docker", "Docker", "\U000f0868 ", (CAT_CLOUD,)), # nf-md-docker
|
|
111
|
+
Icon("docker_whale", "Docker (whale)", "\uf308 ", (CAT_CLOUD,)), # nf-fa-docker
|
|
112
|
+
Icon("kubernetes", "Kubernetes", "\U000f10fe ", (CAT_CLOUD,)), # nf-md-kubernetes
|
|
113
|
+
Icon("kubernetes_alt", "Kubernetes (alt)", "\ue0b6 ", (CAT_CLOUD,)),
|
|
114
|
+
Icon("aws", "AWS", "\ue7ad ", (CAT_CLOUD,)), # nf-dev-aws
|
|
115
|
+
Icon("aws_alt", "AWS (alt)", "\uf270 ", (CAT_CLOUD,)), # nf-fa-aws
|
|
116
|
+
Icon("gcp", "Google Cloud", "\ue7b3 ", (CAT_CLOUD,)), # nf-dev-google_cloud_platform
|
|
117
|
+
Icon("gcp_cloud", "Google Cloud (cloud)", "\uf0c2 ", (CAT_CLOUD,)), # nf-fa-cloud
|
|
118
|
+
Icon("azure", "Azure", "\U000f0825 ", (CAT_CLOUD,)), # nf-md-microsoft_azure
|
|
119
|
+
Icon("terraform", "Terraform", "\U000f1062 ", (CAT_CLOUD,)), # nf-md-terraform
|
|
120
|
+
Icon("terraform_alt", "Terraform (alt)", "\ue0a3 ", (CAT_CLOUD,)),
|
|
121
|
+
Icon("nix", "Nix", "\U000f1105 ", (CAT_CLOUD,)), # nf-md-nix
|
|
122
|
+
Icon("ansible", "Ansible", "\uf195 ", (CAT_CLOUD,)), # nf-fa-building
|
|
123
|
+
Icon("helm", "Helm", "\uf298 ", (CAT_CLOUD,)), # nf-fa-ship
|
|
124
|
+
Icon("cloud", "Cloud", "\uf0c2 ", (CAT_CLOUD,)), # nf-fa-cloud
|
|
125
|
+
Icon("server_alt", "Server (alt)", "\U000f051b ", (CAT_CLOUD,)), # nf-md-server
|
|
126
|
+
Icon("shield", "Shield", "\uf132 ", (CAT_CLOUD,)), # nf-fa-shield
|
|
127
|
+
|
|
128
|
+
# -- Shell -------------------------------------------------------------------
|
|
129
|
+
Icon("prompt_arrow", "Prompt arrow", "\u276f ", (CAT_SHELL,)), # ❯ — standard Unicode, not Nerd Font
|
|
130
|
+
Icon("prompt_dollar", "Dollar sign", "$ ", (CAT_SHELL,)),
|
|
131
|
+
Icon("prompt_lambda", "Lambda", "\u03bb ", (CAT_SHELL,)), # λ — standard Unicode
|
|
132
|
+
Icon("prompt_star", "Star prompt", "\uf005 ", (CAT_SHELL,)), # nf-fa-star
|
|
133
|
+
Icon("prompt_bang", "Bang", "! ", (CAT_SHELL,)),
|
|
134
|
+
Icon("jobs", "Background jobs (sparkle)", "\uf005 ", (CAT_SHELL,)), # nf-fa-star
|
|
135
|
+
Icon("jobs_alt", "Background jobs (gear)", "\uf013 ", (CAT_SHELL,)), # nf-fa-cog
|
|
136
|
+
Icon("error_x", "Error (X)", "\uf00d ", (CAT_SHELL,)), # nf-fa-times
|
|
137
|
+
Icon("error_x_circle", "Error (X in circle)", "\uf057 ", (CAT_SHELL,)), # nf-fa-times_circle
|
|
138
|
+
Icon("error_bang", "Error (warning)", "\uf071 ", (CAT_SHELL,)), # nf-fa-warning
|
|
139
|
+
Icon("error_skull", "Error (skull)", "\U000f05dc ", (CAT_SHELL,)), # nf-md-skull
|
|
140
|
+
Icon("shell_depth", "Shell depth (arrows)", "\uf0aa ", (CAT_SHELL,)), # nf-fa-angle_double_up
|
|
141
|
+
Icon("clock_alt", "Clock (alarm)", "\uf017 ", (CAT_SHELL,)),
|
|
142
|
+
Icon("user", "User", "\uf007 ", (CAT_SHELL,)), # nf-fa-user
|
|
143
|
+
Icon("host", "Host / server", "\uf233 ", (CAT_SHELL,)), # nf-fa-server
|
|
144
|
+
)
|
|
145
|
+
|
|
146
|
+
ICONS_BY_KEY: dict[str, Icon] = {i.key: i for i in ICONS}
|
|
147
|
+
ICON_CATEGORIES: tuple[str, ...] = (CAT_GENERAL, CAT_GIT, CAT_LANG, CAT_CLOUD, CAT_SHELL)
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
def icons_by_category() -> dict[str, list[Icon]]:
|
|
151
|
+
"""Group icons by category, preserving declaration order within each group."""
|
|
152
|
+
grouped: dict[str, list[Icon]] = {cat: [] for cat in ICON_CATEGORIES}
|
|
153
|
+
for icon in ICONS:
|
|
154
|
+
for cat in icon.categories:
|
|
155
|
+
if cat in grouped:
|
|
156
|
+
grouped[cat].append(icon)
|
|
157
|
+
return grouped
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
def find_icon_by_glyph(glyph: str) -> Icon | None:
|
|
161
|
+
"""The icon whose glyph matches, or None. Used to mark the current choice in
|
|
162
|
+
the picker — a section's default icon is a raw glyph, not a catalog key."""
|
|
163
|
+
for icon in ICONS:
|
|
164
|
+
if icon.glyph == glyph:
|
|
165
|
+
return icon
|
|
166
|
+
return None
|
|
@@ -788,6 +788,13 @@ class StarshipConfig:
|
|
|
788
788
|
# Off gives starship's own "no runtime versions" look: the language sections still
|
|
789
789
|
# say *which* toolchain a project uses, without the number nobody reads.
|
|
790
790
|
show_versions: bool = True
|
|
791
|
+
# Per-section overrides chosen in the wizard's "Customize" steps. A colour
|
|
792
|
+
# override is a literal starship colour (hex or ANSI name) that replaces the
|
|
793
|
+
# section's palette role; an icon override is a glyph/text string that replaces
|
|
794
|
+
# the section's default symbol. Both are keyed by section key and empty dicts
|
|
795
|
+
# mean "use the palette/section defaults" — the common path.
|
|
796
|
+
color_overrides: dict[str, str] = field(default_factory=dict)
|
|
797
|
+
icon_overrides: dict[str, str] = field(default_factory=dict)
|
|
791
798
|
|
|
792
799
|
# -- resolved views the emitter and previews share ----------------------
|
|
793
800
|
|
|
@@ -818,14 +825,27 @@ class StarshipConfig:
|
|
|
818
825
|
return left, right
|
|
819
826
|
|
|
820
827
|
def symbol(self, section: Section) -> str:
|
|
821
|
-
"""The glyph for this section under the current preset
|
|
822
|
-
|
|
828
|
+
"""The glyph for this section under the current preset, honouring any
|
|
829
|
+
per-section icon override from the wizard's "Customize icons" step."""
|
|
830
|
+
if section.key in self.icon_overrides:
|
|
831
|
+
symbol = self.icon_overrides[section.key]
|
|
832
|
+
else:
|
|
833
|
+
symbol = section.icon if self.preset_spec.nerd_font else section.plain
|
|
823
834
|
if section.takes_version and not self.show_versions:
|
|
824
835
|
# Every versioned body is `$symbol$version`, so with the version gone the
|
|
825
836
|
# symbol's trailing space would sit at the end of the segment.
|
|
826
837
|
symbol = symbol.rstrip()
|
|
827
838
|
return symbol
|
|
828
839
|
|
|
840
|
+
def section_color(self, section: Section) -> str:
|
|
841
|
+
"""The colour this section renders in — a per-section override if one was
|
|
842
|
+
set in the wizard, otherwise the section's palette role name (which
|
|
843
|
+
starship resolves against the emitted ``[palettes.<name>]`` table). Both
|
|
844
|
+
forms are valid in a starship style string, so the emitter and the offline
|
|
845
|
+
preview can use this uniformly."""
|
|
846
|
+
override = self.color_overrides.get(section.key)
|
|
847
|
+
return override if override is not None else section.role
|
|
848
|
+
|
|
829
849
|
def body(self, section: Section) -> str:
|
|
830
850
|
"""The module's format body under the current preset — what goes inside
|
|
831
851
|
`[…]($style)`. The emitter and the offline preview both derive from this, so
|
|
@@ -48,15 +48,19 @@ def _val(value: Any) -> str:
|
|
|
48
48
|
return _multiline_lit(text) if "\n" in text else _lit(text)
|
|
49
49
|
|
|
50
50
|
|
|
51
|
-
def _runs(sections: list[Section]) -> list[list[Section]]:
|
|
52
|
-
"""Group *consecutive* sections that share a
|
|
51
|
+
def _runs(sections: list[Section], *, color_of=None) -> list[list[Section]]:
|
|
52
|
+
"""Group *consecutive* sections that share a resolved colour.
|
|
53
53
|
|
|
54
54
|
Powerline draws one bar per run, so two adjacent language segments share a
|
|
55
|
-
background instead of getting an arrow between two identical colours.
|
|
55
|
+
background instead of getting an arrow between two identical colours. Grouping
|
|
56
|
+
by the *resolved* colour (override or role) means a per-section colour override
|
|
57
|
+
correctly splits a run that would otherwise share a bar — and two adjacent
|
|
58
|
+
sections overridden to the same colour still merge.
|
|
56
59
|
"""
|
|
57
60
|
runs: list[list[Section]] = []
|
|
58
61
|
for section in sections:
|
|
59
|
-
|
|
62
|
+
color = color_of(section) if color_of else section.role
|
|
63
|
+
if runs and (color_of(runs[-1][0]) if color_of else runs[-1][0].role) == color:
|
|
60
64
|
runs[-1].append(section)
|
|
61
65
|
else:
|
|
62
66
|
runs.append([section])
|
|
@@ -64,9 +68,10 @@ def _runs(sections: list[Section]) -> list[list[Section]]:
|
|
|
64
68
|
|
|
65
69
|
|
|
66
70
|
def _module_style(cfg: StarshipConfig, section: Section) -> str:
|
|
71
|
+
color = cfg.section_color(section)
|
|
67
72
|
if cfg.preset_spec.powerline:
|
|
68
|
-
return f"fg:bar_text bg:{
|
|
69
|
-
return f"fg:{
|
|
73
|
+
return f"fg:bar_text bg:{color}"
|
|
74
|
+
return f"fg:{color}"
|
|
70
75
|
|
|
71
76
|
|
|
72
77
|
def _module_format(cfg: StarshipConfig, section: Section, *, right: bool) -> str:
|
|
@@ -86,14 +91,14 @@ def _left_format(cfg: StarshipConfig, left: list[Section]) -> list[str]:
|
|
|
86
91
|
pieces: list[str] = []
|
|
87
92
|
pl = cfg.preset_spec.powerline
|
|
88
93
|
if pl and left:
|
|
89
|
-
runs = _runs(left)
|
|
90
|
-
pieces.append(f"[{pl.cap_left}](fg:{runs[0][0]
|
|
94
|
+
runs = _runs(left, color_of=cfg.section_color)
|
|
95
|
+
pieces.append(f"[{pl.cap_left}](fg:{cfg.section_color(runs[0][0])})")
|
|
91
96
|
for i, run in enumerate(runs):
|
|
92
97
|
if i:
|
|
93
|
-
prev = runs[i - 1][0]
|
|
94
|
-
pieces.append(f"[{pl.sep}](fg:{prev} bg:{run[0]
|
|
98
|
+
prev = cfg.section_color(runs[i - 1][0])
|
|
99
|
+
pieces.append(f"[{pl.sep}](fg:{prev} bg:{cfg.section_color(run[0])})")
|
|
95
100
|
pieces.extend(s.ref for s in run)
|
|
96
|
-
pieces.append(f"[{pl.sep}](fg:{runs[-1][0]
|
|
101
|
+
pieces.append(f"[{pl.sep}](fg:{cfg.section_color(runs[-1][0])})")
|
|
97
102
|
else:
|
|
98
103
|
pieces.extend(s.ref for s in left)
|
|
99
104
|
|
|
@@ -110,14 +115,14 @@ def _right_format(cfg: StarshipConfig, right: list[Section]) -> str:
|
|
|
110
115
|
if not pl:
|
|
111
116
|
return "".join(s.ref for s in right)
|
|
112
117
|
|
|
113
|
-
runs = _runs(right)
|
|
114
|
-
parts = [f"[{pl.sep_left}](fg:{runs[0][0]
|
|
118
|
+
runs = _runs(right, color_of=cfg.section_color)
|
|
119
|
+
parts = [f"[{pl.sep_left}](fg:{cfg.section_color(runs[0][0])})"]
|
|
115
120
|
for i, run in enumerate(runs):
|
|
116
121
|
if i:
|
|
117
|
-
prev = runs[i - 1][0]
|
|
118
|
-
parts.append(f"[{pl.sep_left}](fg:{run[0]
|
|
122
|
+
prev = cfg.section_color(runs[i - 1][0])
|
|
123
|
+
parts.append(f"[{pl.sep_left}](fg:{cfg.section_color(run[0])} bg:{prev})")
|
|
119
124
|
parts.extend(s.ref for s in run)
|
|
120
|
-
parts.append(f"[{pl.cap_right}](fg:{runs[-1][0]
|
|
125
|
+
parts.append(f"[{pl.cap_right}](fg:{cfg.section_color(runs[-1][0])})")
|
|
121
126
|
return "".join(parts)
|
|
122
127
|
|
|
123
128
|
|
|
@@ -197,11 +202,21 @@ def to_toml(cfg: StarshipConfig) -> str:
|
|
|
197
202
|
|
|
198
203
|
|
|
199
204
|
def _rich_color(color: str) -> str:
|
|
200
|
-
"""
|
|
201
|
-
the separator (`bright-black` vs Rich's `bright_black`)."""
|
|
205
|
+
"""A palette colour (hex or ANSI name) → Rich colour. Hex passes through; ANSI
|
|
206
|
+
names differ only in the separator (`bright-black` vs Rich's `bright_black`)."""
|
|
202
207
|
return color if color.startswith("#") else color.replace("-", "_")
|
|
203
208
|
|
|
204
209
|
|
|
210
|
+
def _resolve_for_rich(cfg: StarshipConfig, section: Section) -> str:
|
|
211
|
+
"""The Rich colour string for this section. A role name (returned by
|
|
212
|
+
``section_color`` when there is no override) is resolved through the palette;
|
|
213
|
+
a literal override (hex or ANSI name) is passed through ``_rich_color``."""
|
|
214
|
+
color = cfg.section_color(section)
|
|
215
|
+
if color in cfg.palette_spec.colors:
|
|
216
|
+
color = cfg.color(color)
|
|
217
|
+
return _rich_color(color)
|
|
218
|
+
|
|
219
|
+
|
|
205
220
|
def _sample_parts(cfg: StarshipConfig, sections: list[Section]) -> list[tuple[str, str]]:
|
|
206
221
|
"""(markup, plain text) for each rendered chunk, so the caller can measure width."""
|
|
207
222
|
parts: list[tuple[str, str]] = []
|
|
@@ -211,23 +226,23 @@ def _sample_parts(cfg: StarshipConfig, sections: list[Section]) -> list[tuple[st
|
|
|
211
226
|
pl = cfg.preset_spec.powerline
|
|
212
227
|
if pl:
|
|
213
228
|
text = _rich_color(cfg.color("bar_text"))
|
|
214
|
-
runs = _runs(sections)
|
|
215
|
-
first =
|
|
229
|
+
runs = _runs(sections, color_of=cfg.section_color)
|
|
230
|
+
first = _resolve_for_rich(cfg, runs[0][0])
|
|
216
231
|
parts.append((f"[{first}]{pl.cap_left}[/]", pl.cap_left))
|
|
217
232
|
for i, run in enumerate(runs):
|
|
218
|
-
bg =
|
|
233
|
+
bg = _resolve_for_rich(cfg, run[0])
|
|
219
234
|
if i:
|
|
220
|
-
prev =
|
|
235
|
+
prev = _resolve_for_rich(cfg, runs[i - 1][0])
|
|
221
236
|
parts.append((f"[{prev} on {bg}]{pl.sep}[/]", pl.sep))
|
|
222
237
|
for section in run:
|
|
223
238
|
body = cfg.sample_text(section)
|
|
224
239
|
parts.append((f"[{text} on {bg}] {escape(body)} [/]", f" {body} "))
|
|
225
|
-
last =
|
|
240
|
+
last = _resolve_for_rich(cfg, runs[-1][0])
|
|
226
241
|
parts.append((f"[{last}]{pl.sep}[/]", pl.sep))
|
|
227
242
|
return parts
|
|
228
243
|
|
|
229
244
|
for i, section in enumerate(sections):
|
|
230
|
-
color =
|
|
245
|
+
color = _resolve_for_rich(cfg, section)
|
|
231
246
|
body = cfg.sample_text(section)
|
|
232
247
|
prefix = "" if i == 0 else " "
|
|
233
248
|
parts.append((f"{prefix}[{color}]{escape(body)}[/]", f"{prefix}{body}"))
|