Runique Admin

`runique start`

The runique start command is the entry point of the admin workflow.

Detecting the admin in `main.rs`

On startup, runique start reads src/main.rs and looks for the presence of .with_admin(:

// src/main.rs
RuniqueApp::builder(config)
    .with_admin(|a| a.routes(admins::routes("/admin")))
    // ...

Detection is done by simple string search in the source file. It works even if the line is commented out (// .with_admin(...)).

Detection resultBehaviour
.with_admin( foundGeneration + cargo run chained
AbsentInfo message, clean exit

The path to main.rs is configurable: runique start --main src/main.rs


What happens when `.with_admin(` is detected

runique start runs, in order, on the same thread:

  1. Generation β€” reads src/admin.rs, parses admin!{}, rewrites src/admins/
  2. cargo fmt --all
  3. cargo run --release β€” blocking until program exit
runique start
  β”œβ”€β”€ generate_admin(src/admin.rs) β†’ rewrites src/admins/
  β”œβ”€β”€ cargo fmt --all
  └── cargo run --release          β†’ HTTP server (blocking)

An earlier design ran generation on a separate thread in parallel with cargo run: this created a race condition (the build could pick up a half-written admin.rs, failing unreproducibly). The flow is now strictly sequential to eliminate that. There is no continuous watching: to regenerate after changing src/admin.rs, run runique start again.


SectionDescription
Admin code generationGenerated files
Macro admin!Declaring administrable resources