From 4a4806a298a2e9a77da2b9ca3daec89c3fda6851 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Fri, 3 Jul 2026 04:46:24 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20Palette:=20Improve=20CLI=20input?= =?UTF-8?q?=20handling=20and=20visual=20feedback?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Strip leading/trailing whitespace from name input - Fallback to 'World' for empty or whitespace-only names - Provide detailed character count in name-too-long error message - Use cyan bold styling for the greeted name to improve visual hierarchy - Update tests to reflect the improved error message - Initialize Palette's UX/Accessibility journal at .jules/palette.md --- project/app.py | 8 ++++++-- tests/test_app.py | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/project/app.py b/project/app.py index e385b11..ed5f59d 100644 --- a/project/app.py +++ b/project/app.py @@ -23,12 +23,16 @@ def main(name: str = "World"): Args: name: the name to be greeted """ + name = name.strip() or "World" + if len(name) > 100: - raise UsageError("Invalid name: maximum length is 100 characters.") + raise UsageError(f"Name too long ({len(name)}/100 characters). Please keep it under 100.") if any(not c.isprintable() for c in name): raise UsageError("Invalid name: control characters are not allowed.") - secho(f"Hello {name}! 👋", fg="green", bold=True) + secho("Hello ", nl=False) + secho(name, fg="cyan", bold=True, nl=False) + secho("! 👋", fg="green", bold=True) if __name__ == "__main__": diff --git a/tests/test_app.py b/tests/test_app.py index 7c414cd..7b9842b 100644 --- a/tests/test_app.py +++ b/tests/test_app.py @@ -30,7 +30,7 @@ def test_name_too_long(): runner = CliRunner() result = runner.invoke(main, ["--name", "A" * 101]) assert result.exit_code != 0 - assert "maximum length is 100 characters" in result.output + assert "Name too long (101/100 characters)" in result.output def test_name_control_characters():