Skip to content

Commit

Permalink
refactor: improve REPL (#940)
Browse files Browse the repository at this point in the history
  • Loading branch information
sigoden authored Oct 20, 2024
1 parent ac89b7a commit a165fd1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions src/repl/completer.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use super::{ReplCommand, REPL_COMMANDS};

use crate::config::GlobalConfig;
use crate::{config::GlobalConfig, utils::fuzzy_match};

use reedline::{Completer, Span, Suggestion};
use std::collections::HashMap;
Expand Down Expand Up @@ -42,7 +42,10 @@ impl Completer for ReplCompleter {
.map(|(v, _)| *v)
.collect::<Vec<&str>>()
.join(" ");
cmd.name.starts_with(&line) && cmd.name != ".set"
if line == "." {
return true;
}
line.starts_with(&cmd.name[..2]) && fuzzy_match(cmd.name, &line)
})
.collect();

Expand Down
2 changes: 1 addition & 1 deletion src/repl/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,9 @@ lazy_static::lazy_static! {
"Regenerate the last response",
AssertState::pass()
),
ReplCommand::new(".copy", "Copy the last response", AssertState::pass()),
ReplCommand::new(".set", "Adjust runtime configuration", AssertState::pass()),
ReplCommand::new(".delete", "Delete roles/sessions/RAGs/agents", AssertState::pass()),
ReplCommand::new(".copy", "Copy the last response", AssertState::pass()),
ReplCommand::new(".exit", "Exit the REPL", AssertState::pass()),
];
static ref COMMAND_RE: Regex = Regex::new(r"^\s*(\.\S*)\s*").unwrap();
Expand Down

0 comments on commit a165fd1

Please sign in to comment.