@smbcloud / cli / commits / 94ee7f9

fix

Seto Elkahfi committed May 29, 2025 at 16:24 UTC 94ee7f98e72c10e0f74768775ecf98ef6f37d500
3 files changed +27 -3
crates/cli/src/deploy/setup.rs
+13 -2
@@ -78,7 +78,7 @@ async fn select_project(env: Environment, projects: Vec<Project>) -> Result<Proj
78 }
79
80 async fn create_new_project(env: Environment) -> Result<Project, ConfigError> {
81 - let project_name = match Input::<String>::with_theme(&ColorfulTheme::default())
81 + let name = match Input::<String>::with_theme(&ColorfulTheme::default())
82 .with_prompt("Project name")
83 .interact()
84 {
@@ -87,6 +87,16 @@ async fn create_new_project(env: Environment) -> Result<Project, ConfigError> {
87 return Err(ConfigError::MissingConfig);
88 }
89 };
90 + let repository = match Input::<String>::with_theme(&ColorfulTheme::default())
91 + .default(name.clone())
92 + .with_prompt("Repository")
93 + .interact()
94 + {
95 + Ok(project_name) => project_name,
96 + Err(_) => {
97 + return Err(ConfigError::MissingConfig);
98 + }
99 + };
100 let description = match Input::<String>::with_theme(&ColorfulTheme::default())
101 .with_prompt("Description")
102 .interact()
@@ -100,7 +110,8 @@ async fn create_new_project(env: Environment) -> Result<Project, ConfigError> {
110 match create_project(
111 env,
112 ProjectCreate {
103 - name: project_name,
113 + name,
114 + repository,
115 description,
116 },
117 )
crates/cli/src/project/crud_create.rs
+12 -1
@@ -6,7 +6,7 @@ use crate::{
6 use anyhow::{anyhow, Result};
7 use console::style;
8 use dialoguer::{theme::ColorfulTheme, Input};
9 -use smbcloud_model::project::ProjectCreate;
9 +use smbcloud_model::project::{self, ProjectCreate};
10 use smbcloud_networking::environment::Environment;
11 use smbcloud_networking_project::create_project;
12 use spinners::Spinner;
@@ -23,6 +23,15 @@ pub async fn process_project_init(env: Environment) -> Result<CommandResult> {
23 return Err(anyhow!(fail_message("Invalid project name.")));
24 }
25 };
26 + let repository = match Input::<String>::with_theme(&ColorfulTheme::default())
27 + .with_prompt("Project name")
28 + .interact()
29 + {
30 + Ok(project_name) => project_name,
31 + Err(_) => {
32 + return Err(anyhow!(fail_message("Invalid project name.")));
33 + }
34 + };
35 let description = match Input::<String>::with_theme(&ColorfulTheme::default())
36 .with_prompt("Description")
37 .interact()
@@ -44,6 +53,7 @@ pub async fn process_project_init(env: Environment) -> Result<CommandResult> {
53 env,
54 ProjectCreate {
55 name: project_name.clone(),
56 + repository,
57 description: description.clone(),
58 },
59 )
@@ -73,6 +83,7 @@ async fn setup_smb_folder(name: &str, description: &str) -> Result<()> {
83 name = "{name}"
84 description = "{description}"
85 [repository]
86 +id = 1
87 name = "{repository_name}"
88 "#,
89 ),
crates/smbcloud-model/src/project.rs
+2
@@ -40,6 +40,7 @@ impl Display for Project {
40 #[derive(Serialize, Debug)]
41 pub struct ProjectCreate {
42 pub name: String,
43 + pub repository: String,
44 pub description: String,
45 }
46
@@ -77,6 +78,7 @@ mod tests {
78 fn test_project_create() {
79 let project_create = ProjectCreate {
80 name: "test".to_owned(),
81 + repository: "test".to_owned(),
82 description: "test".to_owned(),
83 };
84 let json = json!({