@@ -10,38 +10,52 @@ use tokio::sync::Mutex;
10
10
11
11
#[ derive( Clone , FieldAccess ) ]
12
12
pub struct Args {
13
+ pub auditor_mode : bool ,
14
+ pub input_config : CliArgsInputConfig ,
15
+ pub output_config : CliArgsOutputConfig ,
16
+ pub common_config : CliArgsCommonConfig ,
17
+ }
18
+
19
+ #[ derive( Debug , Clone ) ]
20
+ pub struct CliArgsInputConfig {
13
21
pub root : String ,
14
- pub output : String ,
15
22
pub src : Option < String > ,
16
23
pub path_excludes : Option < Vec < String > > ,
17
24
pub path_includes : Option < Vec < String > > ,
25
+ }
26
+
27
+ #[ derive( Debug , Clone ) ]
28
+ pub struct CliArgsOutputConfig {
29
+ pub output : String ,
30
+ pub stdout : bool ,
18
31
pub no_snippets : bool ,
32
+ }
33
+
34
+ #[ derive( Debug , Clone ) ]
35
+ pub struct CliArgsCommonConfig {
36
+ pub lsp : bool ,
19
37
pub skip_cloc : bool ,
20
- pub stdout : bool ,
21
- pub auditor_mode : bool ,
22
38
pub highs_only : bool ,
23
- pub lsp : bool ,
24
39
}
25
40
26
41
/// One way pipeline. Used by CLI
27
42
pub fn kick_off_report_creation ( args : Args ) {
28
- // Choose the detectors
29
43
let detectors = detector_list ( & args) ;
30
44
31
45
let run_pipeline = || -> Result < ( ) , Box < dyn std:: error:: Error > > {
32
- let cx_wrapper = make_context ( & args) . unwrap_or_else ( |e| {
33
- eprintln ! ( "Error making context: {}" , e) ;
34
- std:: process:: exit ( 1 ) ;
35
- } ) ;
46
+ let cx_wrapper =
47
+ make_context ( & args. input_config , & args. common_config ) . unwrap_or_else ( |e| {
48
+ eprintln ! ( "Error making context: {}" , e) ;
49
+ std:: process:: exit ( 1 ) ;
50
+ } ) ;
36
51
37
52
if args. auditor_mode {
38
53
run_auditor_mode ( & cx_wrapper. contexts ) ?;
39
54
} else {
40
55
let root_rel_path = cx_wrapper. root_path ;
41
- let output = args. output . clone ( ) ;
42
56
43
57
// Load the workspace context into the run function, which runs the detectors
44
- run_detector_mode ( & cx_wrapper. contexts , output , root_rel_path, detectors, & args) ?;
58
+ run_detector_mode ( & cx_wrapper. contexts , root_rel_path, detectors, & args. output_config ) ?;
45
59
}
46
60
Ok ( ( ) )
47
61
} ;
@@ -55,10 +69,9 @@ pub fn kick_off_report_creation(args: Args) {
55
69
56
70
/// Drives and returns results. Used by LSP
57
71
pub fn fetch_report_for_lsp ( args : Args ) -> Arc < Mutex < Option < LspReport > > > {
58
- // Choose the detectors
59
72
let detectors = detector_list ( & args) ;
60
73
61
- let ctx_wrapper = match make_context ( & args) {
74
+ let ctx_wrapper = match make_context ( & args. input_config , & args . common_config ) {
62
75
Ok ( ctx_wrapper) => ctx_wrapper,
63
76
Err ( _) => {
64
77
return Arc :: new ( tokio:: sync:: Mutex :: new ( None ) ) ;
@@ -74,6 +87,6 @@ pub fn fetch_report_for_lsp(args: Args) -> Arc<Mutex<Option<LspReport>>> {
74
87
fn detector_list ( args : & Args ) -> Vec < Box < dyn IssueDetector > > {
75
88
get_all_issue_detectors ( )
76
89
. into_iter ( )
77
- . filter ( |d| !args. highs_only || d. severity ( ) == IssueSeverity :: High )
90
+ . filter ( |d| !args. common_config . highs_only || d. severity ( ) == IssueSeverity :: High )
78
91
. collect ( )
79
92
}
0 commit comments