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

Method execute

atomic-cli/src/commands/team/list.rs:75–124  ·  view source on GitHub ↗
(&self)

Source from the content-addressed store, hash-verified

73
74impl TeamList {
75 async fn execute(&self) -> CliResult<()> {
76 let client = build_client(self.org.as_deref(), None).await?;
77 let slug = client.org_slug().to_string();
78
79 let teams = atomic_teams::team::list_teams(&client, &slug)
80 .await
81 .map_err(|e| CliError::RemoteError {
82 message: e.to_string(),
83 url: None,
84 })?;
85
86 let is_json = self
87 .format
88 .as_deref()
89 .map(|f| f.eq_ignore_ascii_case("json"))
90 .unwrap_or(false);
91
92 if is_json {
93 let json = serde_json::to_string_pretty(&teams).map_err(|e| {
94 CliError::Internal(anyhow::anyhow!("Failed to serialize teams: {e}"))
95 })?;
96 println!("{json}");
97 } else if teams.is_empty() {
98 print_hint("No teams found in this organization.");
99 print_hint("Use 'atomic team create <name>' to create one.");
100 } else {
101 let mut table = Table::new();
102 table.set_columns(vec![
103 Column::new("NAME").min_width(20),
104 Column::new("SLUG").min_width(20),
105 Column::new("VISIBILITY").min_width(10),
106 Column::new("CREATED").min_width(20),
107 ]);
108
109 for team in &teams {
110 table.add_row(vec![
111 team.name.clone(),
112 team.slug.clone(),
113 team.visibility.to_string(),
114 team.created_at.to_rfc3339(),
115 ]);
116 }
117
118 println!("{table}");
119
120 print_hint(&format!("{} team(s) total", teams.len()));
121 }
122
123 Ok(())
124 }
125}
126
127#[cfg(test)]

Callers 1

runMethod · 0.45

Calls 7

build_clientFunction · 0.85
list_teamsFunction · 0.85
print_hintFunction · 0.85
org_slugMethod · 0.80
set_columnsMethod · 0.80
add_rowMethod · 0.80
is_emptyMethod · 0.45

Tested by

no test coverage detected