| 76 | |
| 77 | impl Command for ProjectUpdate { |
| 78 | fn run(&self) -> CliResult<()> { |
| 79 | // Ensure at least one field is being updated. |
| 80 | if self.name.is_none() |
| 81 | && self.description.is_none() |
| 82 | && self.default_view.is_none() |
| 83 | && self.visibility.is_none() |
| 84 | { |
| 85 | return Err(CliError::InvalidArgument { |
| 86 | message: "At least one of --name, --description, --default-view, or --visibility must be provided.".to_string(), |
| 87 | }); |
| 88 | } |
| 89 | |
| 90 | let (ws_slug, proj_slug) = parse_project_path(&self.slug)?; |
| 91 | |
| 92 | let rt = tokio::runtime::Runtime::new().map_err(|e| { |
| 93 | CliError::Internal(anyhow::anyhow!("Failed to create async runtime: {}", e)) |
| 94 | })?; |
| 95 | |
| 96 | rt.block_on(async { |
| 97 | let client = build_client(self.org.as_deref(), None).await?; |
| 98 | |
| 99 | let req = UpdateProjectRequest { |
| 100 | name: self.name.clone(), |
| 101 | description: self.description.clone(), |
| 102 | default_view: self.default_view.clone(), |
| 103 | visibility: self.visibility, |
| 104 | }; |
| 105 | |
| 106 | let project = client |
| 107 | .update_project(ws_slug, proj_slug, &req) |
| 108 | .await |
| 109 | .map_err(remote_err)?; |
| 110 | |
| 111 | print_success(&format!("Updated project: {}", project.name)); |
| 112 | |
| 113 | Ok(()) |
| 114 | }) |
| 115 | } |
| 116 | } |
| 117 | |
| 118 | #[cfg(test)] |