(&self)
| 71 | |
| 72 | impl OrgList { |
| 73 | async fn execute(&self) -> CliResult<()> { |
| 74 | let client = build_client(self.org.as_deref(), None).await?; |
| 75 | let slug = client.org_slug().to_string(); |
| 76 | |
| 77 | let info = atomic_teams::org::get_org(&client, &slug) |
| 78 | .await |
| 79 | .map_err(|e| CliError::RemoteError { |
| 80 | message: e.to_string(), |
| 81 | url: None, |
| 82 | })?; |
| 83 | |
| 84 | let is_json = self |
| 85 | .format |
| 86 | .as_deref() |
| 87 | .map(|f| f.eq_ignore_ascii_case("json")) |
| 88 | .unwrap_or(false); |
| 89 | |
| 90 | if is_json { |
| 91 | let json = serde_json::to_string_pretty(&info).map_err(|e| { |
| 92 | CliError::Internal(anyhow::anyhow!("Failed to serialize org info: {e}")) |
| 93 | })?; |
| 94 | println!("{json}"); |
| 95 | } else { |
| 96 | print_section("Current organization:"); |
| 97 | println!(); |
| 98 | |
| 99 | let table = KeyValueTable::new() |
| 100 | .add("Name", &info.name) |
| 101 | .add("Slug", &info.slug) |
| 102 | .add("Kind", &info.kind) |
| 103 | .add("Plan", &info.plan); |
| 104 | let table = if let Some(email) = &info.email { |
| 105 | table.add("Email", email) |
| 106 | } else { |
| 107 | table |
| 108 | }; |
| 109 | let table = table |
| 110 | .add("ID", info.id.to_string()) |
| 111 | .add("Created", info.created_at.to_rfc3339()); |
| 112 | |
| 113 | println!("{table}"); |
| 114 | println!(); |
| 115 | print_hint("Use 'atomic org set <slug>' to change the default organization."); |
| 116 | } |
| 117 | |
| 118 | Ok(()) |
| 119 | } |
| 120 | } |
| 121 | |
| 122 | #[cfg(test)] |
no test coverage detected