How would you create a custom build CLI?

I'm currently working on a Rust frontend framework (Perseus), and it involves a significant amount of boilerplate for the user. Having worked with tools like NextJS before, I was wondering if there would be some way I could create a custom build CLI to abstract this away. The issue is that it would need to work with the user's code, optimally being able to import from their code. Given that tools like Trunk and wasm-pack exist, I assume something like this is possible. If so, how would you actually do it?

I would get rid of the boilerplate code by pulling abstractions out into a core crate and then writing a proc macro which combines the user-configurable parts with the core code.

Otherwise if your boilerplate is more than just Rust (i.e. you have a bunch of extra files and a particular directory structure), something like cargo-generate might be helpful.

I had a similar idea, the problem is that I also need to spin up a server and have a separate library. I can do it if the user sets up a separate binary in their crate, but I was wondering if it would be possible to do without that altogether, given that binary is literally all boilerplate. The issue is that that requires importing the rest of the user's code...

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.