Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions tests/test_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,11 @@ def fake_run(self, *args, **kwargs):
run_settings("")

assert called["ran"] is True

def test_switching_categories_retains_dirty_settings(tmp_path, monkeypatch):
monkeypatch.setattr(Path, "home", lambda: tmp_path)
app = SettingsApp()
app._update_dirty_setting("theme", "light")
app.selected_category = "Data"
assert "theme" in app.dirty_settings
assert app.dirty_settings["theme"] == "light"
3 changes: 1 addition & 2 deletions trushell/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ def app_with_lower() -> None:
if len(sys.argv) > 1:
# Create a local copy to avoid mutating the global sys.argv
argv_copy = sys.argv.copy()
argv_copy[1] = argv_copy[1].lower()
if argv_copy[1] not in {"--help", "-h", "version"}:
if argv_copy[1].lower() not in {"--help", "-h", "version"}:
raw = " ".join(argv_copy[1:])
get_kernel().execute_command(raw)
return
Expand Down
9 changes: 5 additions & 4 deletions trushell/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
from dataclasses import dataclass
from datetime import datetime
from pathlib import Path

import typer
from platformdirs import user_config_dir


Expand Down Expand Up @@ -60,8 +58,11 @@ def load(self) -> AppState:
state.z_dirs = file_data.get("z_dirs", {})
except FileNotFoundError:
return state
except Exception:
typer.secho("Unable to load application state. Using defaults.", fg=typer.colors.YELLOW)
except Exception as e:
print(
f"[yellow]Warning: Unable to load application state. "
f" Using defaults.{e}[/yellow]"
)
return state
return state

Expand Down
Loading