Skip to content

feat: link std in lib mode, name the mode, and add generate --dry-run - #58

Merged
Kinflou merged 2 commits into
mainfrom
feat/lib-mode-and-dry-run
Oct 12, 2026
Merged

Kinflou merged 2 commits into
mainfrom
feat/lib-mode-and-dry-run

Conversation

@Kinflou

@Kinflou Kinflou commented Oct 12, 2026

Copy link
Copy Markdown
Member

lib links comline_std instead of inlining std

The machinery was already there — external_std filters std's schemas out
and adds the dependency — it was just off for everyone. The default now
follows the mode, because the two modes differ in whether there is anywhere
to put a dependency: lib writes the package manifest, so the generator adds
comline_std to it and every crate links one shared std; code emits loose
files with no manifest, so all a generator can do is leave a comment naming
the line to add by hand, and inlining stays the honest default there.

A lib crate carried its own private copy of std before this, drifting from
everyone else's. On a schema using std::http::Request, generation drops
from 7 files to 4, and the result builds against the real comline_std.

It stays a default, not a rule: external_std = false on the target or in
[generate] still inlines std in lib mode. --no-external-std joins
--external-std for the same reason — the default is no longer a fixed
false, so either direction can be the one a run needs to override.

The target line names the mode

⚙️  language: rust, version: 1.70.0, mode: lib

The header stays as it was: mode is a per-target decision and would be a lie
up there the moment two targets disagreed.

generate --dry-run

The generators are pure and write_file is the only side effect in this
command, so a dry run is the real run with the write suppressed — what it
prints is what would be written, not a prediction of it. That matters most
for lib, where out often points outside the project entirely:

• Generating code - dry run, nothing written
  ⚙️  language: rust, version: 1.70.0, mode: lib
       ../libdemo-rs/
       ├─ Cargo.toml
       └─ src/
          ├─ greeting.rs
          ├─ lib.rs
          └─ types.rs
✓ Would write 4 file(s)

comline new scaffolds src/greeting.ids

main is a reserved schema name as of ComlineProject/core#91, so the scaffold
names itself after what it declares, like the repo's own examples/ do. Five
test fixtures that used the name move to api.ids for the same reason.

Three places still claimed code was the only implemented mode — the
generate long help, the --mode flag help and the scaffolded
comline.toml's own comment. lib has worked since G2a; only dylib is
unbuilt.

Depends on ComlineProject/core#91, ComlineProject/generation#46,
ComlineProject/comline-rust#37 and ComlineProject/comline-typescript#31.

…run`

**`lib` links `comline_std` instead of inlining std.** The machinery was
already there - `external_std` filters std's schemas out and adds the
dependency - it was just off for everyone. Now the default follows the mode,
because the two modes differ in whether there is anywhere to put a
dependency: `lib` writes the package manifest, so the generator adds
`comline_std` to it and every crate links one shared std; `code` emits loose
files with no manifest, so all a generator can do is leave a comment naming
the line to add by hand, and inlining stays the honest default there.

A `lib` crate carried its own private copy of std before this, drifting from
everyone else's. On a schema using `std::http::Request`, generation drops
from 7 files to 4.

It stays a default, not a rule: `external_std = false` on the target or in
`[generate]` still inlines std in `lib` mode. `--no-external-std` joins
`--external-std` for the same reason - the default is no longer a fixed
`false`, so either direction can be the one a run needs to override.

**The target line names the mode.** `language: rust, version: 1.70.0,
mode: lib`. The header stays as it was: mode is a per-target decision and
would be a lie up there the moment two targets disagreed.

**`generate --dry-run`** prints the tree each target would write and writes
nothing. The generators are pure and `write_file` is the only side effect in
this command, so a dry run is the real run with the write suppressed - what
it prints is what *would* be written, not a prediction of it. That matters
most for `lib`, where `out` often points outside the project entirely:

    • Generating code - dry run, nothing written
      ⚙️  language: rust, version: 1.70.0, mode: lib
           ../libdemo-rs/
           ├─ Cargo.toml
           └─ src/
              ├─ greeting.rs
              ├─ lib.rs
              └─ types.rs
    ✓ Would write 4 file(s)

**`comline new` scaffolds `src/greeting.ids`.** `main` is a reserved schema
name as of core#91, so the scaffold names itself after what it declares,
like the repo's own `examples/` do. Five test fixtures that used the name
move to `api.ids` for the same reason.

Three places still claimed `code` was the only implemented mode - the
`generate` long help, the `--mode` flag help and the scaffolded
`comline.toml`'s own comment. `lib` has worked since G2a; only `dylib` is
unbuilt.
Including comline-rust#38's STD_REV repoint, so a `lib`-mode crate this CLI
generates links the current comline_std rather than the one the previous pin
named. `comline-codegen` stays on the rev the generator crates themselves
pin - cli has no [patch] to unify two of them.
@Kinflou
Kinflou merged commit 677b559 into main Oct 12, 2026
@Kinflou
Kinflou deleted the feat/lib-mode-and-dry-run branch October 12, 2026 18:53
Kinflou pushed a commit that referenced this pull request Oct 12, 2026
The `lib` mode work (#58) landed unformatted, turning CI's Lint job red on
main; this branch added more of the same. `cargo fmt --all` over the four
files it touched, no behaviour change.
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