MCPcopy Create free account
hub / github.com/Wulf/create-rust-app / configure_project

Function configure_project

crates/create-rust-app_cli/src/main.rs:496–623  ·  view source on GitHub ↗
(
    query_sync: bool,
    qsync_input_files: Option<Vec<PathBuf>>,
    qsync_output_file: Option<PathBuf>,
    qsync_debug: bool,
    new_service: bool,
)

Source from the content-addressed store, hash-verified

494}
495
496fn configure_project(
497 query_sync: bool,
498 qsync_input_files: Option<Vec<PathBuf>>,
499 qsync_output_file: Option<PathBuf>,
500 qsync_debug: bool,
501 new_service: bool,
502) -> Result<()> {
503 let current_dir: PathBuf = fs::get_current_working_directory()?;
504
505 if !current_dir.exists() {
506 println!("Fatal: the current directory doesn't exist. This shouldn't be possible.");
507 return Ok(());
508 }
509
510 if !fs::is_rust_project(&current_dir)? {
511 // TODO: determine if the current directory is a create-rust-app project.
512 println!("Fatal: the current directory is not a rust project.");
513 return Ok(());
514 }
515
516 // println!("It looks like you ran `create-rust-app` without a [name] argument in a rust project directory.");
517 // println!("This functionality has been temporarily disabled in v3 due to our migration to the poem framework. There are plans to support multiple backend frameworks in the future (specifically: actix_web, rocket, axum, warp, and poem).");
518 // println!("\nIf you were trying to create a rust app, include the name argument like so:\n\t{}", style("create-rust-app <project_name>").cyan());
519 // return Ok(());
520
521 let selection = if query_sync && new_service {
522 panic!("--qsync and --new-service are mutually exclusive")
523 } else if query_sync {
524 Some(0)
525 } else if new_service {
526 Some(1)
527 } else {
528 let items = vec![
529 "Generate react-query hooks (beta)",
530 "Add a model & service (beta)",
531 "Cancel",
532 ];
533
534 Select::with_theme(&ColorfulTheme::default())
535 .items(&items)
536 .default(0)
537 .interact_on_opt(&Term::stderr())?
538 };
539
540 if let Some(index) = selection {
541 match index {
542 0 => {
543 // TODO: maybe obtain this programmatically by parsing the users cargo.toml file?
544 logger::message("Which backend framework are you using?");
545 logger::message("Use UP/DOWN arrows to navigate and SPACE or ENTER to confirm.");
546 let items = vec!["actix_web", "poem"];
547 let selection = Select::with_theme(&ColorfulTheme::default())
548 .items(&items)
549 .default(0)
550 .interact_on_opt(&Term::stderr())?;
551
552 match selection {
553 Some(0) => BackendFramework::ActixWeb,

Callers 1

mainFunction · 0.85

Calls 8

is_rust_projectFunction · 0.85
messageFunction · 0.85
processFunction · 0.85
create_resourceFunction · 0.85
errorFunction · 0.85
to_stringMethod · 0.80
defaultMethod · 0.45

Tested by

no test coverage detected