File tree Expand file tree Collapse file tree
crates/emmylua_doc_cli/src Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -4,8 +4,8 @@ use std::path::PathBuf;
44#[ derive( Debug , Parser ) ]
55pub 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" ) ]
Original file line number Diff line number Diff 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
Original file line number Diff line number Diff line change @@ -11,12 +11,34 @@ mod markdown_generator;
1111
1212fn 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+ match current_path. join ( path) . to_str ( ) {
20+ Some ( p) => {
21+ files. push ( p. to_string ( ) ) ;
22+ }
23+ None => {
24+ eprintln ! ( "Error: {} is not a valid path." , path. to_str( ) . unwrap( ) ) ;
25+ exit ( 1 ) ;
26+ }
27+ }
28+ } else {
29+ match path. to_str ( ) {
30+ Some ( p) => {
31+ files. push ( p. to_string ( ) ) ;
32+ }
33+ None => {
34+ eprintln ! ( "Error: {} is not a valid path." , path. to_str( ) . unwrap( ) ) ;
35+ exit ( 1 ) ;
36+ }
37+ }
38+ }
1739 }
1840
19- let analysis = init:: load_workspace ( vec ! [ input . to_str ( ) . unwrap ( ) ] ) ;
41+ let analysis = init:: load_workspace ( files ) ;
2042 if let Some ( mut analysis) = analysis {
2143 let res = match args. format {
2244 Format :: Markdown => markdown_generator:: generate_markdown (
You can’t perform that action at this time.
0 commit comments