Skip to content

Commit 8d2e382

Browse files
committed
emmylua_doc_cli: 支持多个input
1 parent 614962f commit 8d2e382

File tree

3 files changed

+14
-7
lines changed

3 files changed

+14
-7
lines changed

crates/emmylua_doc_cli/src/cmd_args.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ use std::path::PathBuf;
44
#[derive(Debug, Parser)]
55
pub struct CmdArgs {
66
/// The path of the lua project
7-
#[arg(long, short)]
8-
pub input: PathBuf,
7+
#[arg(long, short, num_args = 1..)]
8+
pub input: Vec<PathBuf>,
99

1010
/// Format of the output, default is Markdown
1111
#[arg(long, short, default_value = "markdown")]

crates/emmylua_doc_cli/src/init.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use emmylua_code_analysis::{
55
};
66

77
#[allow(unused)]
8-
pub fn load_workspace(workspace_folders: Vec<&str>) -> Option<EmmyLuaAnalysis> {
8+
pub fn load_workspace(workspace_folders: Vec<String>) -> Option<EmmyLuaAnalysis> {
99
let mut analysis = EmmyLuaAnalysis::new();
1010
analysis.init_std_lib(None);
1111

crates/emmylua_doc_cli/src/main.rs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,19 @@ mod markdown_generator;
1111

1212
fn main() {
1313
let args = CmdArgs::parse();
14-
let mut input = args.input;
15-
if input.is_relative() {
16-
input = std::env::current_dir().ok().unwrap().join(&input);
14+
let current_path = std::env::current_dir().ok().unwrap();
15+
let input = args.input;
16+
let mut files: Vec<String> = Vec::new();
17+
for path in &input {
18+
if path.is_relative() {
19+
let abs_path = current_path.join(path).to_str().unwrap().to_string();
20+
files.push(abs_path);
21+
} else {
22+
files.push(path.to_str().unwrap().to_string());
23+
}
1724
}
1825

19-
let analysis = init::load_workspace(vec![input.to_str().unwrap()]);
26+
let analysis = init::load_workspace(files);
2027
if let Some(mut analysis) = analysis {
2128
let res = match args.format {
2229
Format::Markdown => markdown_generator::generate_markdown(

0 commit comments

Comments
 (0)