Skip to content

Commit 52ebd17

Browse files
committed
Add --theme CLI flag and improve textual-ansi theme
- Add --theme CLI argument to override theme on startup - Remove Duplicate from footer bar (still in help menu) - Improve textual-ansi DataTable cursor with black text on blue background
1 parent 0dba4f5 commit 52ebd17

File tree

6 files changed

+31
-15
lines changed

6 files changed

+31
-15
lines changed

sqlit/cli.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ def _extract_connection_url(argv: list[str]) -> tuple[str | None, list[str]]:
6969
"--db-type",
7070
"--name",
7171
"--settings",
72+
"--theme",
7273
"--mock-missing-drivers",
7374
"--mock-install",
7475
"--mock-pipx",
@@ -296,6 +297,7 @@ def _build_runtime(args: argparse.Namespace, startup_mark: float) -> RuntimeConf
296297

297298
return RuntimeConfig(
298299
settings_path=settings_path,
300+
theme=getattr(args, "theme", None),
299301
max_rows=max_rows,
300302
debug_mode=bool(args.debug),
301303
debug_idle_scheduler=bool(args.debug_idle_scheduler),
@@ -372,6 +374,11 @@ def main() -> int:
372374
metavar="PATH",
373375
help="Path to settings JSON file (overrides ~/.sqlit/settings.json)",
374376
)
377+
parser.add_argument(
378+
"--theme",
379+
metavar="NAME",
380+
help="Theme to use (e.g., dracula, gruvbox, tokyo-night, textual-ansi for terminal colors)",
381+
)
375382
parser.add_argument(
376383
"--mock-missing-drivers",
377384
metavar="DB_TYPES",

sqlit/domains/explorer/state/tree_on_connection.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -85,14 +85,7 @@ def get_display_bindings(self, app: InputContext) -> tuple[list[DisplayBinding],
8585
)
8686
)
8787
seen.add("edit_connection")
88-
left.append(
89-
DisplayBinding(
90-
key=resolve_display_key("duplicate_connection") or "D",
91-
label="Duplicate",
92-
action="duplicate_connection",
93-
)
94-
)
95-
seen.add("duplicate_connection")
88+
seen.add("duplicate_connection") # Still in help menu via _setup_actions
9689
left.append(
9790
DisplayBinding(
9891
key=resolve_display_key("move_connection_to_folder") or "m",

sqlit/domains/shell/app/main.css

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -211,22 +211,22 @@
211211
}
212212

213213
.theme-ansi DataTable > .datatable--cursor {
214-
background: ansi_blue 18%;
215-
color: $text;
214+
background: ansi_bright_blue;
215+
color: ansi_black;
216216
}
217217

218218
.theme-ansi DataTable > .datatable--selectrange {
219-
background: ansi_blue 8%;
219+
background: ansi_blue 30%;
220220
color: $text;
221221
}
222222

223223
.theme-ansi DataTable > .datatable--fixed-cursor {
224-
background: ansi_blue 12%;
224+
background: ansi_blue 40%;
225225
color: $text;
226226
}
227227

228228
.theme-ansi DataTable > .datatable--header-cursor {
229-
background: ansi_blue 12%;
229+
background: ansi_blue 40%;
230230
color: $text;
231231
}
232232

sqlit/domains/shell/app/main.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,11 @@ def __init__(
185185
self._last_action_at: float | None = None
186186
self._last_command: str | None = None
187187
self._last_command_at: float | None = None
188-
self._theme_manager = ThemeManager(self, settings_store=self.services.settings_store)
188+
self._theme_manager = ThemeManager(
189+
self,
190+
settings_store=self.services.settings_store,
191+
override_theme=self.services.runtime.theme,
192+
)
189193
self._spinner_index: int = 0
190194
self._spinner_timer: Timer | None = None
191195
# Schema indexing state

sqlit/domains/shell/app/theme_manager.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,15 @@ def suspend(self) -> AbstractContextManager[None]: ...
9494
class ThemeManager:
9595
"""Centralized theme handling for the app."""
9696

97-
def __init__(self, app: ThemeAppProtocol, settings_store: SettingsStoreProtocol | None = None) -> None:
97+
def __init__(
98+
self,
99+
app: ThemeAppProtocol,
100+
settings_store: SettingsStoreProtocol | None = None,
101+
override_theme: str | None = None,
102+
) -> None:
98103
self._app = app
99104
self._settings_store = settings_store or SettingsStore.get_instance()
105+
self._override_theme = override_theme
100106
self._custom_theme_names: set[str] = set()
101107
self._custom_theme_paths: dict[str, Path] = {}
102108
self._light_theme_names: set[str] = set(LIGHT_THEME_NAMES)
@@ -241,6 +247,11 @@ def _register_custom_theme_path(self, path: Path, expected_name: str | None = No
241247
return theme.name
242248

243249
def _init_omarchy_theme(self, settings: dict) -> None:
250+
# CLI --theme flag takes precedence over everything
251+
if self._override_theme and self._override_theme in self._app.available_themes:
252+
self._app._apply_theme_safe(self._override_theme)
253+
return
254+
244255
saved_theme = settings.get("theme")
245256
if not is_omarchy_installed():
246257
self._app._apply_theme_safe(saved_theme or DEFAULT_THEME)

sqlit/shared/app/runtime.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ class RuntimeConfig:
3030
"""Runtime configuration provided by CLI or tests."""
3131

3232
settings_path: Path | None = None
33+
theme: str | None = None
3334
max_rows: int | None = None
3435
debug_mode: bool = False
3536
debug_idle_scheduler: bool = False

0 commit comments

Comments
 (0)