Skip to content

feat: rewrite leddy on flags-2-env, modularize, add offline preview - #4

Merged
ORESoftware merged 2 commits into
mainfrom
cli-flags2env-rewrite
Aug 8, 2026
Merged

feat: rewrite leddy on flags-2-env, modularize, add offline preview#4
ORESoftware merged 2 commits into
mainfrom
cli-flags2env-rewrite

Conversation

@ORESoftware

Copy link
Copy Markdown
Contributor

The CLI was a single main.rs driving clap. It is now a modular crate whose surface is declared in .cli-flags.toml, and it uses all three org layers instead of two.

flags-2-env

  • .cli-flags.toml is the CLI contract. --help and both shell completions are rendered from it by the statically linked C core at runtime — there is no usage string in Rust to drift, and --help is subcommand-aware.
  • Command-scoped flags: --width / --height / --at exist under preview only. Elsewhere they are rejected unknown options rather than silently ignored ones.
  • src/cli_config.rs is generated from the contract; CI diffs it against fresh generator output.
  • LEDDY_API_TOKEN is an [env] ignore entry — usable from the environment, never a flag, because a flag value is visible in ps output and shell history.

New: leddy preview

Renders the message locally as ASCII art with no device and no network, through leddy_lib::render_message_frame — the same renderer the panel runs, so this is not a lookalike reimplementation:

$ leddy preview --text "HI LEDDY" --width 48 --height 8 --at 2000
cli-1786061928883  48x8 at 2000 ms  (47 px wide, 3959 ms/cycle)
#...#..###........#.....#####.###...###...#...#.
#...#...#.........#.....#.....#..#..#..#..#...#.
#...#...#.........#.....#.....#...#.#...#.#...#.
#####...#.........#.....####..#...#.#...#..#.#..
#...#...#.........#.....#.....#...#.#...#...#...
#...#...#.........#.....#.....#..#..#..#....#...
#...#..###........#####.#####.###...###.....#...
................................................

It is the fastest way to check whether a message fits before publishing it. A finished --repeat once message reports a blank display rather than failing.

Org dependencies — all three layers now real

  • leddy-lib is now a real dependency. Previously only interfaces and clients were used; cycle length and rendering both come from it now.
  • Message and geometry validation is leddy-interfaces' own validate(). The protocol limits are not restated here, so they cannot quietly diverge.
  • The Cargo entries deliberately carry no rev: leddy-lib and leddy-clients both depend on leddy-interfaces by plain git URL, and cargo only unifies git sources whose specs match. Pinning a rev here would fork leddy-interfaces into two crates and the shared types would stop being the same type. Cargo.lock still pins the exact commits.
  • scripts/check-zed-dependencies.py replaces check-zed-package.py. It checks the same three edges and that each one is a real Cargo dependency — a zed manifest that names a repo which does not exist looks right and never resolves.

Layout

main.rs is argv-in/exit-code-out. flags, help, message, commands/, output, and error each do one job. preview and completion never start a runtime or an HTTP client — being offline is part of what they are, so Command::needs_network decides that once, in the dispatcher.

unsafe_code is denied crate-wide; src/help.rs is the single module that opts itself out for the C bindings.

Exit codes

0 success · 1 runtime (device unreachable) · 2 usage · 3 unreadable contract.

26 tests pass; cargo clippy -- -D warnings and cargo fmt --check are clean.

🤖 Generated with Claude Code

alexddl329 and others added 2 commits August 6, 2026 19:20
The CLI was a single main.rs driving clap. It is now a modular crate whose
surface is declared in .cli-flags.toml, and it uses all three org layers
instead of two.

flags-2-env
- .cli-flags.toml is the CLI contract. --help and both shell completions are
  rendered from it by the statically linked C core at runtime, so there is no
  usage string in Rust to drift.
- Command-scoped flags: --width/--height/--at exist under preview only, and are
  rejected unknown options elsewhere.
- src/cli_config.rs is generated from the contract; CI diffs it for drift.
- LEDDY_API_TOKEN is an [env] ignore entry: usable from the environment, never
  a flag, because a flag value is visible in ps output and shell history.

new: leddy preview
- Renders the message locally as ASCII art with no device and no network,
  through leddy_lib::render_message_frame — the same renderer the panel runs,
  so it is not a lookalike reimplementation.
- A finished `--repeat once` message reports a blank display rather than
  failing.

org dependencies
- leddy-lib is now a real dependency: message cycle length and rendering both
  come from it. Previously only interfaces and clients were used.
- Message and geometry validation is leddy-interfaces' own validate(); the
  protocol limits are not restated here.
- Cargo entries deliberately carry no rev: leddy-lib and leddy-clients depend
  on leddy-interfaces by plain git URL, and cargo only unifies git sources
  whose specs match. A rev here would fork leddy-interfaces into two crates.
- scripts/check-zed-dependencies.py replaces check-zed-package.py and also
  verifies every declared zed edge is a real Cargo dependency.

layout: main.rs is argv-in/exit-code-out; flags, help, message, commands/,
output, and error each do one job. preview and completion never start a runtime
or an HTTP client — Command::needs_network decides that once, in the dispatcher.
unsafe_code is denied crate-wide, with src/help.rs the single module that opts
out for the C bindings.

Exit codes: 2 usage, 3 config, 1 runtime. 26 tests pass.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
ORESoftware/flags-2-env#25 merged, so the pin moves from 8a978ae to 8c84655
(flags-2-env 0.2.0). That removes the silent truncation of an inline
--flag=value whose token ran past ~97 characters, which affected long paths,
URLs, JSON payloads, and bearer tokens.

The 'known upstream limitation' note in the README is dropped because it is no
longer true.

Tests pass on the new rev.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

Copy link
Copy Markdown
Contributor Author

Cross-agent coordination review: this complements DEN-2343 rather than duplicating the API/E2E work. Both ci and zed-package are green at exact head 8bd81d8. The offline preview path uses the canonical leddy-lib renderer and the shared interfaces, so it gives us a useful software-only validation surface for the vertical slice. I’m merging this and will build the virtual-device/API/E2E work against the resulting main.

@ORESoftware
ORESoftware merged commit 5adb8c6 into main Aug 8, 2026
4 checks passed
@ORESoftware
ORESoftware deleted the cli-flags2env-rewrite branch August 8, 2026 03:58
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.

2 participants