@@ -4,6 +4,7 @@ use clap::{CommandFactory, Parser};
44use clap_complete:: CompleteEnv ;
55use color_eyre:: Result ;
66use keyring:: set_global_service_name;
7+ use self_update:: cargo_crate_version;
78use tokio:: { runtime:: Handle , sync:: mpsc} ;
89use tuirealm:: {
910 Application , EventListenerCfg , PollStrategy , Sub , SubClause , SubEventClause , Update ,
@@ -67,6 +68,12 @@ async fn main() -> Result<()> {
6768 match args. command {
6869 Some ( command) => match command {
6970 CliCommands :: Version => println ! ( "{}" , version( ) ) ,
71+ CliCommands :: Update => {
72+ tokio:: task:: spawn_blocking ( move || {
73+ update ( ) . unwrap ( ) ;
74+ } )
75+ . await ?
76+ }
7077 CliCommands :: Completions { generator } => {
7178 let mut cmd = Cli :: command ( ) ;
7279 print_completions ( generator, & mut cmd) ;
@@ -372,3 +379,20 @@ fn popup_exclusion_clause() -> SubClause<Id> {
372379 SubClause :: IsMounted ( Id :: SystemSelectPopup ) ,
373380 ] ) ) )
374381}
382+
383+ fn update ( ) -> Result < ( ) > {
384+ let status = self_update:: backends:: github:: Update :: configure ( )
385+ . repo_owner ( "SwissDataScienceCenter" )
386+ . repo_name ( "coman" )
387+ . bin_name ( "coman" )
388+ . show_download_progress ( true )
389+ . current_version ( cargo_crate_version ! ( ) )
390+ . build ( ) ?
391+ . update ( ) ?;
392+ if status. updated ( ) {
393+ println ! ( "Successfully updated to version: `{}`" , status. version( ) ) ;
394+ } else {
395+ println ! ( "Already up to date at version: `{}`" , status. version( ) ) ;
396+ }
397+ Ok ( ( ) )
398+ }
0 commit comments