Skip to content

Commit 9dfab85

Browse files
committed
Apply hotfixes
1 parent 248f457 commit 9dfab85

File tree

1 file changed

+27
-2
lines changed

1 file changed

+27
-2
lines changed

fontspector-cli/src/main.rs

+27-2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ struct Args {
1414
#[clap(short, long, parse(from_occurrences))]
1515
verbose: usize,
1616

17+
/// Hotfix
18+
#[clap(short, long)]
19+
hotfix: bool,
20+
1721
/// Log level
1822
#[clap(short, long, arg_enum, value_parser, default_value_t=StatusCode::Warn)]
1923
loglevel: StatusCode,
@@ -94,14 +98,35 @@ fn main() {
9498
.filter(|c| c.status.code >= args.loglevel)
9599
{
96100
println!(">> {:}", result.check_id);
97-
println!(" {:}", result.check_name);
101+
if args.verbose > 1 {
102+
println!(" {:}", result.check_name);
103+
}
98104
if let Some(filename) = &result.filename {
99105
println!(" with {:}\n", filename);
100106
}
101107
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+
}
103111
}
104112
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");
105130
}
106131
}
107132
}

0 commit comments

Comments
 (0)