lunatic-solutions / lunatic

Lunatic is an Erlang-inspired runtime for WebAssembly
https://lunatic.solutions
Apache License 2.0
4.57k stars 136 forks source link

Add new command #179

Closed sid-707 closed 1 year ago

sid-707 commented 1 year ago

This PR adds a new command to Lunatic: lunatic new <project-name>.

It generates a new Lunatic Rust project with the name <project-name> by performing the following steps: 1) Run cargo new <project_name> to create the project. 2) Change the directory to <project_name>. 3) Add the latest version of Lunatic as a dependency to the project. 4) Run the init command to add the .cargo/config.toml file. 5) Replace Cargo's default src/main.rs with an example that uses Lunatic.

The example program is a modified version of Bernard's example from Writing Rust the Erlang way.

mpope9 commented 1 year ago

Is there any status on merging this? I was considering adding a kind of scaffold like Phoenix has based off of my current HTTP server setup. It'd register a supervisor, a simple submillisecond HTTP server, register the server under the supervisor, maybe a database connection and setup the .cargo/config.toml file. Maybe something like lunatic new.rust.sub_ms...

bkolobara commented 1 year ago

I'm a bit in doubt if we should keep extending the lunatic CLI with additional commands for setting up projects.

What I like at the moment is that you can easily just stick to cargo commands to start a new project and don't need to learn a new CLI tool. Should we maybe just extend cargo with cargo submillisecond.new, cargo lunatic.new, ...?

This would let us keep the runtime focused on more runtime specific "stuff", instead of also being a collection of starter project layouts.

sid-707 commented 1 year ago

I'm a bit in doubt if we should keep extending the lunatic CLI with additional commands for setting up projects.

What I like at the moment is that you can easily just stick to cargo commands to start a new project and don't need to learn a new CLI tool. Should we maybe just extend cargo with cargo submillisecond.new, cargo lunatic.new, ...?

This would let us keep the runtime focused on more runtime specific "stuff", instead of also being a collection of starter project layouts.

I like the cargo approach more now that you mention it. It makes sense to let lunatic remain as just a runtime and not have any starter project layouts.

Just a suggestion: How about cargo sub.new for a new submillisecond project?

Starting a Phoenix project is just mix phx.new.