summaryrefslogtreecommitdiffstats
path: root/src/repl
diff options
context:
space:
mode:
authorsigoden <sigoden@gmail.com>2024-05-01 16:00:48 +0800
committerGitHub <noreply@github.com>2024-05-01 16:00:48 +0800
commite3116280c6e1e2a74b483df09723ceee55ae704c (patch)
tree5bc5a7d1f015c5b3040d48c224d806fe2b3aef49 /src/repl
parentc4c948a54ca84a95986ddf29384c7f057248f42a (diff)
downloadaichat-e3116280c6e1e2a74b483df09723ceee55ae704c.tar.gz
refactor: `.file` repl command files/text split (#472)
Diffstat (limited to 'src/repl')
-rw-r--r--src/repl/mod.rs9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/repl/mod.rs b/src/repl/mod.rs
index 4c50c2f..29b4a43 100644
--- a/src/repl/mod.rs
+++ b/src/repl/mod.rs
@@ -212,10 +212,11 @@ impl Repl {
}
".file" => match args {
Some(args) => {
- let (files, text) = match args.split_once(" -- ") {
- Some((files, text)) => (files.trim(), text.trim()),
- None => (args, ""),
- };
+ let (files, text) =
+ match args.split_once(" -- ").or_else(|| args.split_once(" --\n")) {
+ Some((files, text)) => (files.trim(), text.trim()),
+ None => (args, ""),
+ };
let files = shell_words::split(files).with_context(|| "Invalid args")?;
let input = Input::new(text, files, self.config.read().input_context())?;
self.ask(input).await?;