Repository navigation
v0.6.2
Added
duho.text.kebabcase(s) -> str(alsoduho.kebabcase) — acronym-aware
kebab-case: splits on a lower/digit→Upper boundary, on an Upper letter
followed by Upper+lower (an acronym run stays together up to its last
letter:ShowHTTPStatus→show-http-status, unlikesnakecase's
letter-by-letter handling), and on one or more_(never a leading,
trailing, or doubled-:_Private→private). This is the rule now
behind a class-derived command name and a field's default long flag (see
Fixed, below).- A flag tuple may use
"--"as shorthand for a field's own default long
flag:("--",)→("--dry-run",),("-n", "--")→("-n", "--name").
Any other entry passes through unchanged. A tuple with"--"more than
once raises a build-timeValueErrornaming the field. duho.utf8_stdio(streams=None) -> list[str]— reconfigures
sys.stdout/sys.stderr(or an explicitstreams=mapping) to UTF-8 in
place, skipping a real terminal, a stream already UTF-8, a stream with no
.reconfigure(), Python's own UTF-8 mode, or an explicit
PYTHONIOENCODING. Never raises; idempotent.duho.main/duho.appcall
it first thing, before the MCP launch trigger and beforeargvis parsed.
Opt out with a root class attribute_utf8_stdio_ = False(declared on
Cli, defaultTrue) or amain(..., utf8_stdio=...)/
app(..., utf8_stdio=...)kwarg (wins over the class attribute).
Changed
- Piped/redirected stdout and stderr on a non-UTF-8 host locale (Windows'
defaultcp1252for captured output, most notably) are now reconfigured
to UTF-8 by default instead of raisingUnicodeEncodeErroron the first
non-ASCII character. Seeduho.utf8_stdioabove for the opt-out.
Fixed
- A class with no own
_parsername_is now named with the kebab-case of its
class name, as intended, instead of the exact (mixed-case) class name:
BuildPyz→build-pyz. Visible everywhere a resolved command name is
used — the--helpusage/prog, the subcommand name on the CLI, and
LoggingArgs's default logger name. An explicit_parsername_, an
app(name=...), a_parseraliases_alias, and a discovered MODULE
command's own file-stem name are unaffected — only the bare class-name
fallback was ever wrong. Two sibling commands whose names now collide
(FooBarandFoo_Barboth kebab tofoo-bar) raise a clear build-time
ValueErrornaming both classes, the same as an explicit duplicate
_parsername_on two siblings does. - A field's default long flag (no declared flag tuple) is likewise
kebab-case of the field name, not the older plainname.replace("_", "-"):
testMe→--test-me,HTTPPort→--http-port. An already-snake_case
name is unaffected (dry_run→--dry-run, same as before), and an
explicitly spelled flag, the field's own attribute/dest name, a config/env
key, and a positional name are all untouched. --versionno longer crashes withUnicodeEncodeErrorwhen the resolved
version or program name contains a character outside the stdout stream's
encoding and UTF-8 stdio wasn't already in effect (opted out, or a
duho-built parser used outsidemain/app). The injected--version
action now writes through the same crash-proof path--helpalready
used, falling back toerrors="backslashreplace"instead of raising.
duho's own stderr messages (an unsupported MCP transport, aduho.mcp/
duho.scaffoldCLI error) go through the same path instead of a raw
print(..., file=sys.stderr).
Full Changelog: v0.6.1...v0.6.2