MCPcopy Create free account
hub / github.com/aws/amazon-q-developer-cli / execute

Method execute

crates/chat-cli/src/cli/chat/cli/profile.rs:140–482  ·  view source on GitHub ↗
(self, os: &mut Os, session: &mut ChatSession)

Source from the content-addressed store, hash-verified

138
139impl AgentSubcommand {
140 pub async fn execute(self, os: &mut Os, session: &mut ChatSession) -> Result<ChatState, ChatError> {
141 let agents = &session.conversation.agents;
142
143 macro_rules! _print_err {
144 ($err:expr) => {
145 execute!(
146 session.stderr,
147 StyledText::error_fg(),
148 style::Print(format!("\nError: {}\n\n", $err)),
149 StyledText::reset(),
150 )?
151 };
152 }
153
154 match self {
155 Self::List => {
156 let profiles = agents.agents.values().collect::<Vec<_>>();
157 let active_profile = agents.get_active();
158
159 for (i, profile) in profiles.iter().enumerate() {
160 if active_profile.is_some_and(|p| p == *profile) {
161 queue!(
162 session.stderr,
163 StyledText::success_fg(),
164 style::Print("* "),
165 style::Print(&profile.name),
166 StyledText::reset(),
167 )?;
168 } else {
169 queue!(session.stderr, style::Print(" "), style::Print(&profile.name),)?;
170 }
171
172 if i < profiles.len().saturating_sub(1) {
173 queue!(session.stderr, style::Print("\n"))?;
174 }
175 }
176 execute!(session.stderr, style::Print("\n"))?;
177 },
178 Self::Schema => {
179 use schemars::schema_for;
180
181 let schema = schema_for!(Agent);
182 let pretty = serde_json::to_string_pretty(&schema)
183 .map_err(|e| ChatError::Custom(format!("Failed to convert agent schema to string: {e}").into()))?;
184 highlight_json(&mut session.stderr, pretty.as_str())
185 .map_err(|e| ChatError::Custom(format!("Error printing agent schema: {e}").into()))?;
186 },
187 Self::Create { name, directory, from } => {
188 let mut agents = Agents::load(os, None, true, &mut session.stderr, session.conversation.mcp_enabled)
189 .await
190 .0;
191 let path_with_file_name = create_agent(os, &mut agents, name.clone(), directory, from)
192 .await
193 .map_err(|e| ChatError::Custom(Cow::Owned(e.to_string())))?;
194
195 crate::util::editor::launch_editor(&path_with_file_name)
196 .map_err(|e| ChatError::Custom(Cow::Owned(e.to_string())))?;
197

Callers

nothing calls this directly

Calls 15

CustomClass · 0.85
highlight_jsonFunction · 0.85
create_agentFunction · 0.85
inputFunction · 0.85
dialoguer_themeFunction · 0.85
get_enabled_mcp_serversFunction · 0.85
get_activeMethod · 0.80
to_stringMethod · 0.80
insertMethod · 0.80
kindMethod · 0.80
mapMethod · 0.80

Tested by

no test coverage detected