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
2 changes: 1 addition & 1 deletion .claude-plugin/plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@
"license": "BSD-3-Clause",
"name": "yas",
"repository": "https://github.com/tmck-code/yet-another-statusline",
"version": "0.2.10"
"version": "0.2.11"
}
9 changes: 6 additions & 3 deletions claude/yas/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

from __future__ import annotations

import json
import os
try:
import tomllib
Expand Down Expand Up @@ -54,14 +55,16 @@ def _parse_pos_float(raw: object, origin: str) -> float:
raise ValueError('must be > 0')
return x

BOOL_ALLOWLIST = ('1', '0', 'true', 'false')

def _parse_bool(raw: object, origin: str) -> bool:
if isinstance(raw, bool):
return raw
# Env form: any non-empty value is true (empty strings are filtered out
# before reaching here). A non-bool from yas.toml is a type error.
if origin == 'cli' or origin.startswith('env'):
return True
v = str(raw).strip().lower()
if v not in BOOL_ALLOWLIST:
raise ValueError(f"expected one of {', '.join(BOOL_ALLOWLIST)}")
return bool(json.loads(v))
raise ValueError('expected a boolean')


Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "yet-another-statusline"
version = "0.2.10"
version = "0.2.11"
description = "Claude Code statusline showing info at a glance: tokens, context, model, subagents, burn rate, skills, plugins, OpenSpec specs, task lists, and more"
readme = "README.md"

Expand Down
31 changes: 29 additions & 2 deletions test/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,36 @@ def test_toml_full_width_true(tmp_path: Path) -> None:
assert cfg.full_width is True


def test_env_full_width_any_nonempty_is_true(tmp_path: Path) -> None:
def test_env_full_width_truthy_values(tmp_path: Path) -> None:
for val in ('1', 'true', 'True', 'TRUE'):
cfg = config.Config.load(env={'YAS_FULL_WIDTH': val}, config_dir=tmp_path)
assert cfg.full_width is True, f'expected True for YAS_FULL_WIDTH={val!r}'


def test_env_full_width_falsy_values(tmp_path: Path) -> None:
for val in ('0', 'false', 'False', 'FALSE'):
cfg = config.Config.load(env={'YAS_FULL_WIDTH': val}, config_dir=tmp_path)
assert cfg.full_width is False, f'expected False for YAS_FULL_WIDTH={val!r}'


def test_env_full_width_invalid_falls_through_to_default(tmp_path: Path) -> None:
cfg = config.Config.load(env={'YAS_FULL_WIDTH': 'yes'}, config_dir=tmp_path)
assert cfg.full_width is False # invalid env value → default


@requires_tomllib
def test_env_full_width_zero_overrides_toml_true(tmp_path: Path) -> None:
(tmp_path / 'yas.toml').write_text('[layout]\nfull_width = true\n')
cfg = config.Config.load(env={'YAS_FULL_WIDTH': '0'}, config_dir=tmp_path)
assert cfg.full_width is True
assert cfg.full_width is False


@requires_tomllib
def test_env_max_width_respected_when_full_width_disabled(tmp_path: Path) -> None:
(tmp_path / 'yas.toml').write_text('[layout]\nfull_width = true\n')
cfg = config.Config.load(env={'YAS_FULL_WIDTH': '0', 'YAS_MAX_WIDTH': '40'}, config_dir=tmp_path)
assert cfg.full_width is False
assert cfg.max_width == 40


# 4.4 Broken TOML + unknown keys
Expand Down
2 changes: 1 addition & 1 deletion uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.