Make the linux upgrade function a method

This commit is contained in:
Roey Darwish Dror
2018-10-02 10:46:38 +03:00
parent 2d79246fab
commit 15cec667b0
2 changed files with 33 additions and 24 deletions

View File

@@ -108,13 +108,23 @@ fn run() -> Result<(), Error> {
&mut terminal,
));
#[cfg(target_os = "linux")]
let distribution = linux::Distribution::detect();
#[cfg(target_os = "linux")]
{
if !opt.no_system {
report.push_result(execute(
|terminal| linux::upgrade(&sudo, terminal, opt.dry_run),
&mut terminal,
));
match distribution {
Ok(distribution) => {
report.push_result(execute(
|terminal| distribution.upgrade(&sudo, terminal, opt.dry_run),
&mut terminal,
));
}
Err(e) => {
println!("Error detecting current distribution: {}", e);
}
}
}
}