Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: cargo shuttle init #175

Closed
christos-h opened this issue May 16, 2022 · 3 comments · Fixed by #238
Closed

feature: cargo shuttle init #175

christos-h opened this issue May 16, 2022 · 3 comments · Fixed by #238
Assignees
Labels
Contribution Wanted The community is welcome to collaborate on this issue Good First Issue Good for newcomers T-Improvement Improvement or addition to existing features

Comments

@christos-h
Copy link
Member

Introduce an init function to cargo-shuttle that will initialise the barebones of a project (similar to cargo init). cargo shuttle init <name>

This should probably:

  1. Add an Init(ProjectName) variant to Command in args.rs
  2. Call cargo init --lib via the cargo crate
  3. Automatically add the crate-type = ["cdylib"] to cargo.toml
  4. Add the shuttle-service deps top cargo.toml.

Bonus points - have a separate cargo init command for each framework supported. For example with Rocket:

  1. cargo shuttle init-rocket <name>
  2. As above, but also add the feature flags: shuttle-service = { version = "0.2", features = ["web-rocket"] }
  3. Also create hello-world scaffolding
#[macro_use]
extern crate rocket;

use rocket::{Build, Rocket};

#[get("/")]
fn index() -> &'static str {
    "Hello, world!"
}

#[shuttle_service::main]
async fn rocket() -> Result<Rocket<Build>, shuttle_service::Error> {
    Ok(rocket::build().mount("/hello", routes![index]))
}
@christos-h christos-h added T-Improvement Improvement or addition to existing features Good First Issue Good for newcomers Contribution Wanted The community is welcome to collaborate on this issue labels May 16, 2022
@christos-h christos-h moved this to Considering in Feature Requests Roadmap May 16, 2022
@nahuakang
Copy link
Contributor

nahuakang commented May 26, 2022

I'd be happy to claim this if no one else is working on it yet and it's not high priority time-wise on shuttle's roadmap :)

Edit: After asking around and doing some investigation, it seems that cargo init writes naively to files and we could use toml-edit for modifying an existing Cargo.toml file.

@brokad
Copy link
Collaborator

brokad commented May 26, 2022

I'd be happy to claim this if no one else is working on it yet and it's not high priority time-wise on shuttle's roadmap :)

Thanks @nahuakang!

Edit: After asking around and doing some investigation, it seems that cargo init writes naively to files and we could use toml-edit for modifying an existing Cargo.toml file.

Sounds like a plan!

@brokad brokad assigned brokad and nahuakang and unassigned brokad May 26, 2022
@brokad brokad moved this from Considering to In Progress in Feature Requests Roadmap May 26, 2022
@nahuakang
Copy link
Contributor

First PR is merged. I'll start working on the bonus points (might be off for a few days but will definitely continue on the issue) :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Contribution Wanted The community is welcome to collaborate on this issue Good First Issue Good for newcomers T-Improvement Improvement or addition to existing features
Projects
No open projects
Development

Successfully merging a pull request may close this issue.

3 participants