@@ -14,6 +14,10 @@ struct Args {
14
14
#[ clap( short, long, parse( from_occurrences) ) ]
15
15
verbose : usize ,
16
16
17
+ /// Hotfix
18
+ #[ clap( short, long) ]
19
+ hotfix : bool ,
20
+
17
21
/// Log level
18
22
#[ clap( short, long, arg_enum, value_parser, default_value_t=StatusCode :: Warn ) ]
19
23
loglevel : StatusCode ,
@@ -94,14 +98,35 @@ fn main() {
94
98
. filter ( |c| c. status . code >= args. loglevel )
95
99
{
96
100
println ! ( ">> {:}" , result. check_id) ;
97
- println ! ( " {:}" , result. check_name) ;
101
+ if args. verbose > 1 {
102
+ println ! ( " {:}" , result. check_name) ;
103
+ }
98
104
if let Some ( filename) = & result. filename {
99
105
println ! ( " with {:}\n " , filename) ;
100
106
}
101
107
if let Some ( rationale) = & result. check_rationale {
102
- termimad:: print_inline ( & format ! ( "Rationale:\n \n ```\n {}\n ```\n " , rationale) ) ;
108
+ if args. verbose > 1 {
109
+ termimad:: print_inline ( & format ! ( "Rationale:\n \n ```\n {}\n ```\n " , rationale) ) ;
110
+ }
103
111
}
104
112
termimad:: print_inline ( & format ! ( "Result: **{:}**\n \n " , result. status) ) ;
113
+ if result. status . code != StatusCode :: Fail {
114
+ continue ;
115
+ }
116
+ let check = registry. checks . get ( & result. check_id ) . unwrap ( ) ;
117
+ if let Some ( fix) = check. hotfix {
118
+ if args. hotfix {
119
+ if fix ( & Testable :: new ( result. filename . as_ref ( ) . unwrap ( ) ) ) {
120
+ // XXX
121
+ println ! ( " Hotfix applied" ) ;
122
+ } else {
123
+ println ! ( " Hotfix failed" ) ;
124
+ }
125
+ } else {
126
+ termimad:: print_inline ( " This issue can be fixed automatically. Run with `--hotfix` to apply the fix.\n " )
127
+ }
128
+ }
129
+ println ! ( "\n " ) ;
105
130
}
106
131
}
107
132
}
0 commit comments