@@ -4,17 +4,42 @@ use std::path::PathBuf;
4
4
#[ derive( Debug , Parser ) ]
5
5
#[ command( version) ]
6
6
pub struct CmdArgs {
7
- /// The path of the lua project
8
- #[ arg( long, short, num_args = 1 ..) ]
7
+ /// Configuration file paths.
8
+ /// If not provided, both ".emmyrc.json" and ".luarc.json" will be searched in the workspace
9
+ /// directory
10
+ #[ arg( short, long, value_delimiter = ',' ) ]
11
+ pub config : Option < Vec < PathBuf > > ,
12
+
13
+ /// Deprecated, use [WORKSPACE] instead
14
+ #[ arg( short, long, num_args = 1 ..) ]
9
15
pub input : Vec < PathBuf > ,
10
16
11
- /// Format of the output, default is Markdown
12
- #[ arg( long, short, default_value = "markdown" ) ]
13
- pub format : Format ,
17
+ /// Path to the workspace directory
18
+ #[ arg( num_args = 1 ..) ]
19
+ pub workspace : Vec < PathBuf > ,
20
+
21
+ /// Comma separated list of ignore patterns.
22
+ /// Patterns must follow glob syntax
23
+ #[ arg( long, value_delimiter = ',' ) ]
24
+ pub ignore : Option < Vec < String > > ,
25
+
26
+ /// Specify output format
27
+ #[ arg(
28
+ long,
29
+ short = 'f' ,
30
+ default_value = "markdown" ,
31
+ value_enum,
32
+ ignore_case = true
33
+ ) ]
34
+ pub output_format : Format ,
14
35
15
- /// The output path of the docs file
36
+ /// Deprecated, use --output-format instead
37
+ #[ arg( long, value_enum, ignore_case = true ) ]
38
+ pub format : Option < Format > ,
39
+
40
+ /// Specify output destination (can be stdout when output_format is json)
16
41
#[ arg( long, short, default_value = "./output" ) ]
17
- pub output : PathBuf ,
42
+ pub output : OutputDestination ,
18
43
19
44
/// The path of the override template
20
45
#[ arg( long) ]
@@ -26,22 +51,31 @@ pub struct CmdArgs {
26
51
/// The path of the mixin md file
27
52
#[ arg( long) ]
28
53
pub mixin : Option < PathBuf > ,
54
+
55
+ /// Verbose output
56
+ #[ arg( long) ]
57
+ pub verbose : bool ,
29
58
}
30
59
31
60
#[ derive( Debug , Clone , Eq , PartialEq , ValueEnum ) ]
32
61
pub enum Format {
33
- Markdown ,
34
62
Json ,
63
+ Markdown ,
35
64
}
36
65
37
- impl std:: str:: FromStr for Format {
38
- type Err = & ' static str ;
66
+ #[ allow( unused) ]
67
+ #[ derive( Debug , Clone ) ]
68
+ pub enum OutputDestination {
69
+ Stdout ,
70
+ File ( PathBuf ) ,
71
+ }
39
72
73
+ impl std:: str:: FromStr for OutputDestination {
74
+ type Err = String ;
40
75
fn from_str ( s : & str ) -> Result < Self , Self :: Err > {
41
- match s. to_lowercase ( ) . as_ref ( ) {
42
- "markdown" => Ok ( Self :: Markdown ) ,
43
- "json" => Ok ( Self :: Json ) ,
44
- _ => Err ( "Invalid format, must be one of markdown, json" ) ,
76
+ match s. to_lowercase ( ) . as_str ( ) {
77
+ "stdout" => Ok ( OutputDestination :: Stdout ) ,
78
+ _ => Ok ( OutputDestination :: File ( PathBuf :: from ( s) ) ) ,
45
79
}
46
80
}
47
81
}
0 commit comments