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

Method execute

crates/chat-cli/src/cli/chat/mod.rs:258–460  ·  view source on GitHub ↗
(mut self, os: &mut Os)

Source from the content-addressed store, hash-verified

256
257impl ChatArgs {
258 pub async fn execute(mut self, os: &mut Os) -> Result<ExitCode> {
259 let mut input = self.input;
260
261 if self.no_interactive && input.is_none() {
262 if !std::io::stdin().is_terminal() {
263 let mut buffer = String::new();
264 match std::io::stdin().read_to_string(&mut buffer) {
265 Ok(_) => {
266 if !buffer.trim().is_empty() {
267 input = Some(buffer.trim().to_string());
268 }
269 },
270 Err(e) => {
271 eprintln!("Error reading from stdin: {}", e);
272 },
273 }
274 }
275
276 if input.is_none() {
277 bail!("Input must be supplied when running in non-interactive mode");
278 }
279 }
280
281 let mut stderr = std::io::stderr();
282
283 let args: Vec<String> = std::env::args().collect();
284 if args
285 .iter()
286 .any(|arg| arg == "--profile" || arg.starts_with("--profile="))
287 {
288 execute!(
289 stderr,
290 StyledText::warning_fg(),
291 style::Print("WARNING: "),
292 StyledText::reset(),
293 style::Print("--profile is deprecated, use "),
294 StyledText::success_fg(),
295 style::Print("--agent"),
296 StyledText::reset(),
297 style::Print(" instead\n")
298 )?;
299 }
300
301 let conversation_id = uuid::Uuid::new_v4().to_string();
302 info!(?conversation_id, "Generated new conversation id");
303
304 // Check MCP status once at the beginning of the session
305 let mcp_enabled = match os.client.is_mcp_enabled().await {
306 Ok(enabled) => enabled,
307 Err(err) => {
308 tracing::warn!(?err, "Failed to check MCP configuration, defaulting to enabled");
309 true
310 },
311 };
312
313 let agents = {
314 let skip_migration = self.no_interactive;
315 let (mut agents, md) =

Callers 1

handle_inputMethod · 0.45

Calls 15

get_available_modelsFunction · 0.85
find_modelFunction · 0.85
read_to_stringMethod · 0.80
to_stringMethod · 0.80
is_mcp_enabledMethod · 0.80
get_activeMethod · 0.80
get_boolMethod · 0.80
setMethod · 0.80
get_active_mutMethod · 0.80
get_stringMethod · 0.80
mapMethod · 0.80

Tested by

no test coverage detected