Skip to content

Commit 5d10b7d

Browse files
committed
fix(cli): fix script as input
1 parent cf8a4c2 commit 5d10b7d

1 file changed

Lines changed: 20 additions & 9 deletions

File tree

file_classification_cli/src/bin/file_classification_cli.rs

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -741,16 +741,27 @@ fn handle_command(
741741

742742
println!("执行命令: {}", line);
743743

744-
// 尝试解析为标准命令
745-
let args: Vec<&str> = line.split_whitespace().collect();
746-
if let Ok(cmd) = Cli::try_parse_from(args) {
747-
if let Err(e) = handle_command(cmd, conn, context) {
748-
println!("命令执行错误: {}", e);
744+
// 支持分号分隔的多命令
745+
let commands: Vec<&str> = line.split(';').collect();
746+
for command in commands {
747+
let command = command.trim();
748+
if command.is_empty() {
749+
continue;
749750
}
750-
} else {
751-
// 尝试作为简化命令处理
752-
if !handle_simplified_command(line, conn, context) {
753-
println!("无法解析命令: {}", line);
751+
752+
// 尝试解析为标准命令
753+
let args = shlex::split(command).unwrap_or_default();
754+
let cli_args = std::iter::once("file_classification_cli".to_string()).chain(args);
755+
756+
if let Ok(cmd) = Cli::try_parse_from(cli_args) {
757+
if let Err(e) = handle_command(cmd, conn, context) {
758+
println!("命令执行错误: {}", e);
759+
}
760+
} else {
761+
// 尝试作为简化命令处理
762+
if !handle_simplified_command(command, conn, context) {
763+
println!("无法解析命令: {}", command);
764+
}
754765
}
755766
}
756767
}

0 commit comments

Comments
 (0)