mirror of
https://github.com/veeso/termscp.git
synced 2025-12-07 09:36:00 -08:00
Auto update (w/ cli)
This commit is contained in:
@@ -26,7 +26,11 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
// mod
|
||||
use crate::system::{environment, theme_provider::ThemeProvider};
|
||||
use crate::system::{
|
||||
auto_update::{Update, UpdateStatus},
|
||||
environment,
|
||||
theme_provider::ThemeProvider,
|
||||
};
|
||||
use std::fs;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
@@ -51,6 +55,23 @@ pub fn import_theme(p: &Path) -> Result<(), String> {
|
||||
.map_err(|e| format!("Could not import theme: {}", e))
|
||||
}
|
||||
|
||||
/// ### install_update
|
||||
///
|
||||
/// Install latest version of termscp if an update is available
|
||||
pub fn install_update() -> Result<String, String> {
|
||||
match Update::default()
|
||||
.show_progress(true)
|
||||
.ask_confirm(true)
|
||||
.upgrade()
|
||||
{
|
||||
Ok(UpdateStatus::AlreadyUptodate) => Ok("termscp is already up to date".to_string()),
|
||||
Ok(UpdateStatus::UpdateInstalled(v)) => {
|
||||
Ok(format!("termscp has been updated to version {}", v))
|
||||
}
|
||||
Err(err) => Err(err.to_string()),
|
||||
}
|
||||
}
|
||||
|
||||
/// ### get_config_dir
|
||||
///
|
||||
/// Get configuration directory
|
||||
|
||||
Reference in New Issue
Block a user