@@ -15,6 +15,32 @@ use gitoxide_core::pack::verify;
15
15
use crate :: plumbing:: options:: { Args , Subcommands } ;
16
16
use crate :: shared:: pretty:: prepare_and_run;
17
17
18
+ #[ cfg( feature = "gitoxide-core-async-client" ) ]
19
+ pub mod async_util {
20
+ use crate :: shared:: ProgressRange ;
21
+
22
+ #[ cfg( not( feature = "prodash-render-line" ) ) ]
23
+ compile_error ! ( "BUG: Need at least a line renderer in async mode" ) ;
24
+
25
+ pub fn prepare (
26
+ verbose : bool ,
27
+ name : & str ,
28
+ range : impl Into < Option < ProgressRange > > ,
29
+ ) -> ( Option < prodash:: render:: line:: JoinHandle > , Option < prodash:: tree:: Item > ) {
30
+ use crate :: shared:: { self , STANDARD_RANGE } ;
31
+ crate :: shared:: init_env_logger ( false ) ;
32
+
33
+ if verbose {
34
+ let progress = crate :: shared:: progress_tree ( ) ;
35
+ let sub_progress = progress. add_child ( name) ;
36
+ let ui_handle = shared:: setup_line_renderer_range ( progress, range. into ( ) . unwrap_or ( STANDARD_RANGE ) ) ;
37
+ ( Some ( ui_handle) , Some ( sub_progress) )
38
+ } else {
39
+ ( None , None )
40
+ }
41
+ }
42
+ }
43
+
18
44
pub fn main ( ) -> Result < ( ) > {
19
45
let args: Args = Args :: parse ( ) ;
20
46
let thread_limit = args. threads ;
@@ -101,8 +127,7 @@ pub fn main() -> Result<()> {
101
127
refs,
102
128
refs_directory,
103
129
} => {
104
- let ( _handle, progress) =
105
- crate :: shared:: async_util:: prepare ( verbose, "pack-receive" , core:: pack:: receive:: PROGRESS_RANGE ) ;
130
+ let ( _handle, progress) = async_util:: prepare ( verbose, "pack-receive" , core:: pack:: receive:: PROGRESS_RANGE ) ;
106
131
let fut = core:: pack:: receive (
107
132
protocol,
108
133
& url,
@@ -151,11 +176,8 @@ pub fn main() -> Result<()> {
151
176
) ,
152
177
#[ cfg( feature = "gitoxide-core-async-client" ) ]
153
178
Subcommands :: RemoteRefList { protocol, url } => {
154
- let ( _handle, progress) = crate :: shared:: async_util:: prepare (
155
- verbose,
156
- "remote-ref-list" ,
157
- Some ( core:: remote:: refs:: PROGRESS_RANGE ) ,
158
- ) ;
179
+ let ( _handle, progress) =
180
+ async_util:: prepare ( verbose, "remote-ref-list" , Some ( core:: remote:: refs:: PROGRESS_RANGE ) ) ;
159
181
let fut = core:: remote:: refs:: list (
160
182
protocol,
161
183
& url,
0 commit comments