(&self)
| 82 | |
| 83 | impl Command for WorkspaceList { |
| 84 | fn run(&self) -> CliResult<()> { |
| 85 | let rt = tokio::runtime::Runtime::new().map_err(|e| { |
| 86 | CliError::Internal(anyhow::anyhow!("Failed to create async runtime: {}", e)) |
| 87 | })?; |
| 88 | |
| 89 | rt.block_on(async { |
| 90 | let client = build_client(self.org.as_deref(), self.server.as_deref()).await?; |
| 91 | let workspaces = client.list_workspaces().await.map_err(remote_err)?; |
| 92 | |
| 93 | if self.format == "json" { |
| 94 | println!( |
| 95 | "{}", |
| 96 | serde_json::to_string_pretty(&workspaces).unwrap_or_default() |
| 97 | ); |
| 98 | return Ok(()); |
| 99 | } |
| 100 | |
| 101 | if workspaces.is_empty() { |
| 102 | print_hint( |
| 103 | "No workspaces found. Create one with 'atomic workspace create <name>'.", |
| 104 | ); |
| 105 | return Ok(()); |
| 106 | } |
| 107 | |
| 108 | let mut table = Table::new(); |
| 109 | table.set_columns(vec![ |
| 110 | Column::new("NAME"), |
| 111 | Column::new("SLUG"), |
| 112 | Column::new("VISIBILITY"), |
| 113 | Column::new("CREATED"), |
| 114 | ]); |
| 115 | |
| 116 | for ws in &workspaces { |
| 117 | table.add_row(vec![ |
| 118 | ws.name.clone(), |
| 119 | ws.slug.clone(), |
| 120 | ws.visibility.to_string(), |
| 121 | format_timestamp(&ws.created_at), |
| 122 | ]); |
| 123 | } |
| 124 | |
| 125 | println!("{}", table); |
| 126 | Ok(()) |
| 127 | }) |
| 128 | } |
| 129 | } |
| 130 | |
| 131 | #[cfg(test)] |
nothing calls this directly
no test coverage detected