graphrag_cli/mode.rs
1//! Input utilities for the TUI
2//!
3//! The input box automatically detects whether input is a query or slash command.
4//! - Regular text: Natural language questions
5//! - Text starting with '/': Slash commands
6
7/// Check if input text is a slash command
8pub fn is_slash_command(input: &str) -> bool {
9 input.trim().starts_with('/')
10}
11
12#[cfg(test)]
13mod tests {
14 use super::*;
15
16 #[test]
17 fn test_slash_command_detection() {
18 assert!(is_slash_command("/config file.toml"));
19 assert!(is_slash_command(" /load doc.txt"));
20 assert!(!is_slash_command("What is GraphRAG?"));
21 assert!(!is_slash_command(""));
22 }
23}