Skip to content

0.0.3: value_type<T>() and value_as<T>() — numeric options checked by the parse - #10

Merged
Sunrisepeak merged 4 commits into
mainfrom
feat/value-as
Nov 9, 2026
Merged

Sunrisepeak merged 4 commits into
mainfrom
feat/value-as

Conversation

@Sunrisepeak

Copy link
Copy Markdown
Member

An option declared with value_type<T>() takes a number of type T (std::from_chars); a value that is not wholly one is a parse error (option --rate takes a number, not \fast`), so a program never falls back silently to a default on a typo. ParsedArgs::value_as(name)` reads it back.

Why: omui's programs move their hand-written argv loops onto cmdline (its AGENTS.md: what a library already does is depended on, not written again); mcpp and mtest each parse numbers with from_chars at the call site — this is that check, once, in the library.

  • Option::value_type<T>() / OptBuilder::value_type<T>(): sets takes_value, a value name (NUMBER / N), the check.
  • ParsedArgs::value_as<T>(): the value as T; nothing when absent (or, unchecked, not a number).
  • Tests: 3 new (ValueType.*), 40/40 pass locally (mcpp 2026.11.8.1).
  • Version 0.0.3; README documents it.

…the parse (0.0.3)

An option declared with value_type<T>() takes a number of type T, read with
std::from_chars: a value that is not wholly one (`12px`, `-1` for an
unsigned, out of range) is a parse error — "option --rate takes a number,
not `fast`" — instead of each program checking it, or a bad value falling
back silently to a default. ParsedArgs::value_as<T>(name) reads it back
(nothing when it was not given). The same check mtest's engine makes for
its integer and number parameters, now in the library (cf. mcpp's and
mtest's from_chars at each call site).

Tests: ValueType.* (each type read back; the errors for --long and -s
forms; the builder form; an unchecked value read as nothing). README:
the feature and an example. Version 0.0.3.
…hain from today's index (glibc, gcc-runtime not found)
@Sunrisepeak
Sunrisepeak merged commit db53410 into main Nov 9, 2026
1 check passed
@Sunrisepeak
Sunrisepeak deleted the feat/value-as branch November 9, 2026 06:59
Sunrisepeak added a commit to Sunrisepeak/mui that referenced this pull request Nov 9, 2026
…ine everywhere; one API described (omui describe --api, check --portable); omui package/add/remove/deps/tools/config

Scope:
- AGENTS §5: what a library already does is depended on (mcpplibs.* first, then
  mcpp-index, own code last); §4: a cmdline App is one chained, tree-shaped expression.
- mcpplibs.cmdline 0.0.3 released for it (mcpplibs/cmdline#10: value_type<T>(), a
  numeric option checked by the parse; value_as<T>(); its CI on mcpp 2026.11.8.1),
  in mcpp-index (#742, CN mirror); every cmdline dependency here moved to it.
- SDK: RunOptions::declare/from on cmdline, omui::command_line (a program's switches
  beside openmui's, parsed once); takes_value() gone.
- Every hand-written argv parser moved: the player entry, examples 03/08/09/10, the
  showcases' mains and breakout's playtest, the site (its --lang is RunOptions's;
  first-frame options declared, repeats and strays still refused; --option=value now
  accepted, its test says so), inspector, omui-mcp, omui-gen and dist-toy, gongfu-studio,
  hanim, xengine, omui-music, xrender, the benchmarks, the hanim consumer. Renamed where
  two switches shared a name: omui-fight --computer/--computer-level, --fight P1,P2
  (duel.sh, README); gongfu stage --who A,B (catalog regenerated).
- lint cmdline (29 rules self-tested): a command line scanned by hand is refused
  (tests/bench's programs included).
- One API (W3): view's component_catalog() (omuiCatalog uses it), Theme::describe(),
  omui.agent:api api_of (builders with `spec`, natives, tokens, verbs); protocol
  describe {api: true} (catalog param documented, regenerated); the player entry's
  --types writes api.json; omui describe --api (--json, --llms FILE); omui check
  --portable (an omui import, a builder not the spec's, where each is).
- W15: omui package (mcpp pack, --format), add/remove, deps, tools (xlings says
  what is installed; --install), config (omui.config.ts over the defaults); the
  project commands declared as chained Apps.
- lang.js: tsconfig.json built with nlohmann.json; skill: read the API before writing.

Sample-verified (the user's rule: sample, push, CI verifies): omui.sdk 3/3,
examples hello-im 4/4, markdown-viewer 8/8, counter 5/5, markdown-stream 4/4, space
5/5, omui.cli (project_test 6/6 incl. deps/tools/config, check), omui.mcp 10/10,
inspector 3 programs, omui.gen 5 programs, gongfu.studio 3/3, hanim.studio 2/2,
xengine.audio 2 programs, showcases style 10, breakout 21+8+1, fighting 41+3+3+10,
wall 15; built: omui.entry.player, xrender.tool, omui.bench, competitors; lint 0.
Not run here: the site's suite (CI).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant