@@ -92,10 +92,10 @@ impl Command for GetCommand {
9292 {
9393 Ok ( _matches) => {
9494 let arch = self . get_architecture ( ) ?;
95- writer. writeln ( "Arch" , arch. as_str ( ) ) ;
95+ writer. write_ok ( format ! ( "Arch {} " , arch) . as_str ( ) ) ;
9696
9797 let latest_tag = self . get_latest_tag ( ) ?;
98- writer. writeln ( "Tag" , latest_tag. as_str ( ) ) ;
98+ writer. write_ok ( format ! ( "Tag {} " , latest_tag) . as_str ( ) ) ;
9999
100100 // Create download dir.
101101 let bin_download_dir = format ! (
@@ -112,7 +112,6 @@ impl Command for GetCommand {
112112
113113 let bin_name = format ! ( "datafuse--{}.tar.gz" , arch) ;
114114 let bin_file = format ! ( "{}/{}" , bin_download_dir, bin_name) ;
115- writer. writeln ( "Binary" , bin_file. as_str ( ) ) ;
116115 let exists = Path :: new ( bin_file. as_str ( ) ) . exists ( ) ;
117116
118117 // Download.
@@ -123,7 +122,6 @@ impl Command for GetCommand {
123122 latest_tag,
124123 bin_name,
125124 ) ;
126- writer. writeln ( "Download" , binary_url. as_str ( ) ) ;
127125 let res = ureq:: get ( binary_url. as_str ( ) ) . call ( ) ?;
128126 let total_size: u64 = res. header ( "content-length" ) . unwrap ( ) . parse ( ) . unwrap ( ) ;
129127 let pb = ProgressBar :: new ( total_size) ;
@@ -133,22 +131,33 @@ impl Command for GetCommand {
133131
134132 let mut out = File :: create ( bin_file. clone ( ) ) . unwrap ( ) ;
135133 io:: copy ( & mut pb. wrap_read ( res. into_reader ( ) ) , & mut out) . unwrap ( ) ;
134+ writer. write_ok ( format ! ( "Download {}" , binary_url) . as_str ( ) ) ;
136135 }
136+ writer. write_ok ( format ! ( "Binary {}" , bin_file) . as_str ( ) ) ;
137137
138138 // Unpack.
139139 let tar_gz = File :: open ( bin_file) ?;
140140 let tar = GzDecoder :: new ( tar_gz) ;
141141 let mut archive = Archive :: new ( tar) ;
142- writer. writeln ( "Unpack to" , bin_unpack_dir. as_str ( ) ) ;
143- archive. unpack ( bin_unpack_dir) . unwrap ( ) ;
142+ let res = archive. unpack ( bin_unpack_dir. clone ( ) ) ;
143+ match res {
144+ Ok ( _) => {
145+ writer. write_ok ( format ! ( "Unpack {}" , bin_unpack_dir) . as_str ( ) ) ;
146+ }
147+ Err ( e) => {
148+ writer. write_err ( format ! ( "{}" , e) . as_str ( ) ) ;
149+ return Ok ( ( ) ) ;
150+ }
151+ } ;
144152
145153 // Write status.
146154 let mut status = Status :: read ( self . conf . clone ( ) ) ?;
147155 status. latest = latest_tag;
148156 status. write ( ) ?;
157+ writer. write_ok ( "Write status" ) ;
149158 }
150159 Err ( err) => {
151- writer. writeln_width ( "" , format ! ( "{}" , err) . as_str ( ) , 0 ) ;
160+ writer. write_err ( format ! ( "{}" , err) . as_str ( ) ) ;
152161 }
153162 }
154163
0 commit comments