std::cli into Nikaia: cli.rs becomes cli.nika, same APIOpen and answer this issue on GitHub.
ready · opened 2026-11-21 · updated 2026-11-21 · 0 comments
Part of #449 (subcommands of main, option A) and of self-hosting (#125).
Decision: CLAUDE.md, Written in Nikaia only: the struct options and Command dispatch of ADR-cli-v1 D8-D12 change the runtime that reads main’s words, and that runtime is Rust today (crates/nikaia-std/src/cli.rs, 458 lines). A feature there is built in Nikaia where the code can be converted directly (ADR-294); so the runtime moves first, unchanged.
crates/nikaia-std/src/cli.rs holds Interface, Param (name, ty, kind, default, pre), Kind (Subject, Maybe, Rest, Option, Flag), Words (read, sort, subject, maybe, rest, option, breach), Stop, usage, help, the Word trait with its from_word impls (macros), and args(). emit_entry.nika (main_words_of) writes Rust that calls nikaia_std::cli::Words::read(&__NIKAIA_INTERFACE) and the subject/maybe/rest/option reads.
crates/nikaia-std/src/cli.nika, lowered by Stage 0 like text.nika and supervisor.nika (crates/nikaia-std/src/lib.rs, around lines 85 and 110), with the same names and behaviour: the Rust emit_entry writes keeps compiling unchanged, the help, usage and exit codes (0 for help, 2 for a wrong word) stay byte for byte. cli.rs is deleted.
cli.nika with Interface, Param, Kind, Stop, usage, help, args; lower it; switch lib.rs to the lowered module. Test: the existing cli_words_are_sorted_into_the_parameters.nika, cli_args_walked_by_name.nika, cli_args_walked_twice.nika, cli_article.nika pass unchanged (their .stdout / .stderr untouched).Words and its reads. The Word trait’s per-type from_word (today written with Rust macros) becomes a trait impl per word type in Nikaia. Same tests.cli.rs. Same tests, plus lower-std reproduces the lowered file.The four cli_* tests and every test with a main that takes words pass unchanged; cli.rs is gone; step 3’s commit carries Fixes #N. A form Nikaia lacks for this (e.g. a static slice of structs for params: &[…], a generic read by the expected type) is not written around: Result: blocked, Found: with a probe, Needs: supervisor decision.
Files: crates/nikaia-std/src/cli.nika (new), its lowered .rs, crates/nikaia-std/src/lib.rs, crates/nikaia-std/src/cli.rs (deleted). No new Rust.
Facts: nikaia test --filter cli_ from tests/compiler; docs/builder-facts-lookup.md has the lowering rules (nikaia run scripts/syntax.nika -- lower).
Ruled out: changing behaviour in the move (D8-D12 are the next issues); keeping cli.rs and adding the new fields in Rust (CLAUDE.md, Written in Nikaia only).