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

Function does_input_reference_file

crates/chat-cli/src/cli/chat/mod.rs:3947–3962  ·  view source on GitHub ↗

Checks if an input may be referencing a file and should not be handled as a typical slash command. If true, then return [Option::Some ], otherwise [Option::None].

(input: &str)

Source from the content-addressed store, hash-verified

3945/// Checks if an input may be referencing a file and should not be handled as a typical slash
3946/// command. If true, then return [Option::Some<ChatState>], otherwise [Option::None].
3947fn does_input_reference_file(input: &str) -> Option<ChatState> {
3948 let after_slash = input.strip_prefix("/")?;
3949
3950 if let Some(first) = shlex::split(after_slash).unwrap_or_default().first() {
3951 let looks_like_path =
3952 first.contains(MAIN_SEPARATOR) || first.contains('/') || first.contains('\\') || first.contains('.');
3953
3954 if looks_like_path {
3955 return Some(ChatState::HandleInput {
3956 input: after_slash.to_string(),
3957 });
3958 }
3959 }
3960
3961 None
3962}
3963
3964// Helper method to save the agent config to file
3965async fn save_agent_config(os: &mut Os, config: &Agent, agent_name: &str, is_global: bool) -> Result<(), ChatError> {

Callers 2

handle_inputMethod · 0.85

Calls 1

to_stringMethod · 0.80

Tested by 1