MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / execute

Method execute

atomic-cli/src/commands/org/member.rs:166–226  ·  view source on GitHub ↗
(&self)

Source from the content-addressed store, hash-verified

164
165impl MemberList {
166 async fn execute(&self) -> CliResult<()> {
167 let client = build_client(self.org.as_deref(), None).await?;
168 let slug = client.org_slug().to_string();
169
170 let members = atomic_teams::member::list_members(&client, &slug)
171 .await
172 .map_err(|e| CliError::RemoteError {
173 message: e.to_string(),
174 url: None,
175 })?;
176
177 let is_json = self
178 .format
179 .as_deref()
180 .map(|f| f.eq_ignore_ascii_case("json"))
181 .unwrap_or(false);
182
183 if is_json {
184 let json = serde_json::to_string_pretty(&members).map_err(|e| {
185 CliError::Internal(anyhow::anyhow!("Failed to serialize members: {e}"))
186 })?;
187 println!("{json}");
188 } else if members.is_empty() {
189 print_hint("No members found in this organization.");
190 } else {
191 // The identity UUID is deliberately not a column: it is 36
192 // characters that identify nobody, and `member update`/`remove`
193 // accept a name or email just as well. It stays in `--format json`
194 // for callers that want it.
195 let mut table = Table::new();
196 table.set_columns(vec![
197 Column::new("NAME").min_width(14),
198 Column::new("EMAIL").min_width(22),
199 Column::new("ROLE").min_width(8),
200 Column::new("STATUS").min_width(9),
201 Column::new("KEY").min_width(19),
202 Column::new("JOINED").min_width(20),
203 ]);
204
205 for member in &members {
206 table.add_row(vec![
207 member.name.clone().unwrap_or_else(unknown),
208 member.email.clone().unwrap_or_else(unknown),
209 member.role.to_string(),
210 member.status.clone().unwrap_or_else(unknown),
211 member
212 .public_key
213 .as_deref()
214 .map(short_key)
215 .unwrap_or_else(unknown),
216 member.joined_at.to_rfc3339(),
217 ]);
218 }
219
220 println!("{table}");
221
222 print_hint(&format!("{} member(s) total", members.len()));
223 }

Callers 1

runMethod · 0.45

Calls 15

build_clientFunction · 0.85
list_membersFunction · 0.85
print_hintFunction · 0.85
resolve_identityFunction · 0.85
add_memberFunction · 0.85
print_successFunction · 0.85
update_member_roleFunction · 0.85
print_warningFunction · 0.85
remove_memberFunction · 0.85
org_slugMethod · 0.80
set_columnsMethod · 0.80
add_rowMethod · 0.80

Tested by

no test coverage detected