Skip to content

Commit 43f666f

Browse files
authored
fix(/context): handle filepaths with white spaces (aws#1198)
1 parent df0d83d commit 43f666f

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

crates/q_cli/src/cli/chat/command.rs

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -426,13 +426,18 @@ impl Command {
426426
let mut force = false;
427427
let mut paths = Vec::new();
428428

429-
for part in &parts[2..] {
430-
if *part == "--global" {
429+
let args = match shlex::split(&parts[2..].join(" ")) {
430+
Some(args) => args,
431+
None => return Err("Failed to parse quoted arguments".to_string()),
432+
};
433+
434+
for arg in &args {
435+
if arg == "--global" {
431436
global = true;
432-
} else if *part == "--force" || *part == "-f" {
437+
} else if arg == "--force" || arg == "-f" {
433438
force = true;
434439
} else {
435-
paths.push((*part).to_string());
440+
paths.push(arg.to_string());
436441
}
437442
}
438443

@@ -448,12 +453,16 @@ impl Command {
448453
// Parse rm command with paths and --global flag
449454
let mut global = false;
450455
let mut paths = Vec::new();
456+
let args = match shlex::split(&parts[2..].join(" ")) {
457+
Some(args) => args,
458+
None => return Err("Failed to parse quoted arguments".to_string()),
459+
};
451460

452-
for part in &parts[2..] {
453-
if *part == "--global" {
461+
for arg in &args {
462+
if arg == "--global" {
454463
global = true;
455464
} else {
456-
paths.push((*part).to_string());
465+
paths.push(arg.to_string());
457466
}
458467
}
459468

crates/q_cli/src/cli/chat/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1246,8 +1246,9 @@ where
12461246
)?;
12471247
profile_context_files.extend(context_files);
12481248
}
1249+
execute!(self.output, style::Print("\n"))?;
12491250
}
1250-
execute!(self.output, style::Print("\n\n"))?;
1251+
execute!(self.output, style::Print("\n"))?;
12511252
}
12521253

12531254
if global_context_files.is_empty() && profile_context_files.is_empty() {

0 commit comments

Comments
 (0)