@@ -23,13 +23,13 @@ use crate::utils::utils;
23
23
use crate :: {
24
24
dist:: notifications as dist_notifications, toolchain:: distributable:: DistributableToolchain ,
25
25
} ;
26
- use crate :: { process, toolchain:: toolchain:: Toolchain } ;
26
+ use crate :: { process:: Process , toolchain:: toolchain:: Toolchain } ;
27
27
use crate :: { Cfg , Notification } ;
28
28
29
29
pub ( crate ) const WARN_COMPLETE_PROFILE : & str = "downloading with complete profile isn't recommended unless you are a developer of the rust language" ;
30
30
31
31
pub ( crate ) fn confirm ( question : & str , default : bool ) -> Result < bool > {
32
- write ! ( process ( ) . stdout( ) . lock( ) , "{question} " ) ?;
32
+ write ! ( Process :: get ( ) . stdout( ) . lock( ) , "{question} " ) ?;
33
33
let _ = std:: io:: stdout ( ) . flush ( ) ;
34
34
let input = read_line ( ) ?;
35
35
@@ -40,7 +40,7 @@ pub(crate) fn confirm(question: &str, default: bool) -> Result<bool> {
40
40
_ => false ,
41
41
} ;
42
42
43
- writeln ! ( process ( ) . stdout( ) . lock( ) ) ?;
43
+ writeln ! ( Process :: get ( ) . stdout( ) . lock( ) ) ?;
44
44
45
45
Ok ( r)
46
46
}
@@ -52,15 +52,15 @@ pub(crate) enum Confirm {
52
52
}
53
53
54
54
pub ( crate ) fn confirm_advanced ( customized_install : bool ) -> Result < Confirm > {
55
- writeln ! ( process ( ) . stdout( ) . lock( ) ) ?;
55
+ writeln ! ( Process :: get ( ) . stdout( ) . lock( ) ) ?;
56
56
let first_option = match customized_install {
57
57
true => "1) Proceed with selected options (default - just press enter)" ,
58
58
false => "1) Proceed with standard installation (default - just press enter)" ,
59
59
} ;
60
- writeln ! ( process ( ) . stdout( ) . lock( ) , "{first_option}" ) ?;
61
- writeln ! ( process ( ) . stdout( ) . lock( ) , "2) Customize installation" ) ?;
62
- writeln ! ( process ( ) . stdout( ) . lock( ) , "3) Cancel installation" ) ?;
63
- write ! ( process ( ) . stdout( ) . lock( ) , ">" ) ?;
60
+ writeln ! ( Process :: get ( ) . stdout( ) . lock( ) , "{first_option}" ) ?;
61
+ writeln ! ( Process :: get ( ) . stdout( ) . lock( ) , "2) Customize installation" ) ?;
62
+ writeln ! ( Process :: get ( ) . stdout( ) . lock( ) , "3) Cancel installation" ) ?;
63
+ write ! ( Process :: get ( ) . stdout( ) . lock( ) , ">" ) ?;
64
64
65
65
let _ = std:: io:: stdout ( ) . flush ( ) ;
66
66
let input = read_line ( ) ?;
@@ -71,17 +71,17 @@ pub(crate) fn confirm_advanced(customized_install: bool) -> Result<Confirm> {
71
71
_ => Confirm :: No ,
72
72
} ;
73
73
74
- writeln ! ( process ( ) . stdout( ) . lock( ) ) ?;
74
+ writeln ! ( Process :: get ( ) . stdout( ) . lock( ) ) ?;
75
75
76
76
Ok ( r)
77
77
}
78
78
79
79
pub ( crate ) fn question_str ( question : & str , default : & str ) -> Result < String > {
80
- writeln ! ( process ( ) . stdout( ) . lock( ) , "{question} [{default}]" ) ?;
80
+ writeln ! ( Process :: get ( ) . stdout( ) . lock( ) , "{question} [{default}]" ) ?;
81
81
let _ = std:: io:: stdout ( ) . flush ( ) ;
82
82
let input = read_line ( ) ?;
83
83
84
- writeln ! ( process ( ) . stdout( ) . lock( ) ) ?;
84
+ writeln ! ( Process :: get ( ) . stdout( ) . lock( ) ) ?;
85
85
86
86
if input. is_empty ( ) {
87
87
Ok ( default. to_string ( ) )
@@ -92,12 +92,12 @@ pub(crate) fn question_str(question: &str, default: &str) -> Result<String> {
92
92
93
93
pub ( crate ) fn question_bool ( question : & str , default : bool ) -> Result < bool > {
94
94
let default_text = if default { "(Y/n)" } else { "(y/N)" } ;
95
- writeln ! ( process ( ) . stdout( ) . lock( ) , "{question} {default_text}" ) ?;
95
+ writeln ! ( Process :: get ( ) . stdout( ) . lock( ) , "{question} {default_text}" ) ?;
96
96
97
97
let _ = std:: io:: stdout ( ) . flush ( ) ;
98
98
let input = read_line ( ) ?;
99
99
100
- writeln ! ( process ( ) . stdout( ) . lock( ) ) ?;
100
+ writeln ! ( Process :: get ( ) . stdout( ) . lock( ) ) ?;
101
101
102
102
if input. is_empty ( ) {
103
103
Ok ( default)
@@ -111,7 +111,7 @@ pub(crate) fn question_bool(question: &str, default: bool) -> Result<bool> {
111
111
}
112
112
113
113
pub ( crate ) fn read_line ( ) -> Result < String > {
114
- let stdin = process ( ) . stdin ( ) ;
114
+ let stdin = Process :: get ( ) . stdin ( ) ;
115
115
let stdin = stdin. lock ( ) ;
116
116
let mut lines = stdin. lines ( ) ;
117
117
let lines = lines. next ( ) . transpose ( ) ?;
@@ -250,7 +250,7 @@ fn show_channel_updates(
250
250
Ok ( ( pkg, banner, width, color, version, previous_version) )
251
251
} ) ;
252
252
253
- let mut t = process ( ) . stdout ( ) . terminal ( ) ;
253
+ let mut t = Process :: get ( ) . stdout ( ) . terminal ( ) ;
254
254
255
255
let data: Vec < _ > = data. collect :: < Result < _ > > ( ) ?;
256
256
let max_width = data
@@ -291,7 +291,7 @@ pub(crate) fn update_all_channels(
291
291
292
292
let show_channel_updates = || {
293
293
if !toolchains. is_empty ( ) {
294
- writeln ! ( process ( ) . stdout( ) . lock( ) ) ?;
294
+ writeln ! ( Process :: get ( ) . stdout( ) . lock( ) ) ?;
295
295
296
296
let t = toolchains
297
297
. into_iter ( )
@@ -371,7 +371,7 @@ where
371
371
}
372
372
373
373
pub ( crate ) fn list_targets ( distributable : DistributableToolchain < ' _ > ) -> Result < utils:: ExitCode > {
374
- let mut t = process ( ) . stdout ( ) . terminal ( ) ;
374
+ let mut t = Process :: get ( ) . stdout ( ) . terminal ( ) ;
375
375
let manifestation = distributable. get_manifestation ( ) ?;
376
376
let config = manifestation. read_config ( ) ?. unwrap_or_default ( ) ;
377
377
let manifest = distributable. get_manifest ( ) ?;
@@ -399,7 +399,7 @@ pub(crate) fn list_targets(distributable: DistributableToolchain<'_>) -> Result<
399
399
pub ( crate ) fn list_installed_targets (
400
400
distributable : DistributableToolchain < ' _ > ,
401
401
) -> Result < utils:: ExitCode > {
402
- let t = process ( ) . stdout ( ) ;
402
+ let t = Process :: get ( ) . stdout ( ) ;
403
403
let manifestation = distributable. get_manifestation ( ) ?;
404
404
let config = manifestation. read_config ( ) ?. unwrap_or_default ( ) ;
405
405
let manifest = distributable. get_manifest ( ) ?;
@@ -422,7 +422,7 @@ pub(crate) fn list_installed_targets(
422
422
pub ( crate ) fn list_components (
423
423
distributable : DistributableToolchain < ' _ > ,
424
424
) -> Result < utils:: ExitCode > {
425
- let mut t = process ( ) . stdout ( ) . terminal ( ) ;
425
+ let mut t = Process :: get ( ) . stdout ( ) . terminal ( ) ;
426
426
427
427
let manifestation = distributable. get_manifestation ( ) ?;
428
428
let config = manifestation. read_config ( ) ?. unwrap_or_default ( ) ;
@@ -443,7 +443,7 @@ pub(crate) fn list_components(
443
443
}
444
444
445
445
pub ( crate ) fn list_installed_components ( distributable : DistributableToolchain < ' _ > ) -> Result < ( ) > {
446
- let t = process ( ) . stdout ( ) ;
446
+ let t = Process :: get ( ) . stdout ( ) ;
447
447
for component in distributable. components ( ) ? {
448
448
if component. installed {
449
449
writeln ! ( t. lock( ) , "{}" , component. name) ?;
@@ -471,7 +471,7 @@ fn print_toolchain_path(
471
471
String :: new ( )
472
472
} ;
473
473
writeln ! (
474
- process ( ) . stdout( ) . lock( ) ,
474
+ Process :: get ( ) . stdout( ) . lock( ) ,
475
475
"{}{}{}{}" ,
476
476
& toolchain,
477
477
if_default,
@@ -489,7 +489,7 @@ pub(crate) fn list_toolchains(cfg: &Cfg, verbose: bool) -> Result<utils::ExitCod
489
489
. map ( Into :: into)
490
490
. collect :: < Vec < _ > > ( ) ;
491
491
if toolchains. is_empty ( ) {
492
- writeln ! ( process ( ) . stdout( ) . lock( ) , "no installed toolchains" ) ?;
492
+ writeln ! ( Process :: get ( ) . stdout( ) . lock( ) , "no installed toolchains" ) ?;
493
493
} else {
494
494
let def_toolchain_name = cfg. get_default ( ) ?. map ( |t| ( & t) . into ( ) ) ;
495
495
let cwd = utils:: current_dir ( ) ?;
@@ -527,7 +527,7 @@ pub(crate) fn list_overrides(cfg: &Cfg) -> Result<utils::ExitCode> {
527
527
let overrides = cfg. settings_file . with ( |s| Ok ( s. overrides . clone ( ) ) ) ?;
528
528
529
529
if overrides. is_empty ( ) {
530
- writeln ! ( process ( ) . stdout( ) . lock( ) , "no overrides" ) ?;
530
+ writeln ! ( Process :: get ( ) . stdout( ) . lock( ) , "no overrides" ) ?;
531
531
} else {
532
532
let mut any_not_exist = false ;
533
533
for ( k, v) in overrides {
@@ -536,15 +536,15 @@ pub(crate) fn list_overrides(cfg: &Cfg) -> Result<utils::ExitCode> {
536
536
any_not_exist = true ;
537
537
}
538
538
writeln ! (
539
- process ( ) . stdout( ) . lock( ) ,
539
+ Process :: get ( ) . stdout( ) . lock( ) ,
540
540
"{:<40}\t {:<20}" ,
541
541
utils:: format_path_for_display( & k)
542
542
+ if dir_exists { "" } else { " (not a directory)" } ,
543
543
v
544
544
) ?
545
545
}
546
546
if any_not_exist {
547
- writeln ! ( process ( ) . stdout( ) . lock( ) ) ?;
547
+ writeln ! ( Process :: get ( ) . stdout( ) . lock( ) ) ?;
548
548
info ! (
549
549
"you may remove overrides for non-existent directories with
550
550
`rustup override unset --nonexistent`"
@@ -567,51 +567,51 @@ pub(crate) fn version() -> &'static str {
567
567
pub ( crate ) fn dump_testament ( ) -> Result < utils:: ExitCode > {
568
568
use git_testament:: GitModification :: * ;
569
569
writeln ! (
570
- process ( ) . stdout( ) . lock( ) ,
570
+ Process :: get ( ) . stdout( ) . lock( ) ,
571
571
"Rustup version renders as: {}" ,
572
572
version( )
573
573
) ?;
574
574
writeln ! (
575
- process ( ) . stdout( ) . lock( ) ,
575
+ Process :: get ( ) . stdout( ) . lock( ) ,
576
576
"Current crate version: {}" ,
577
577
env!( "CARGO_PKG_VERSION" )
578
578
) ?;
579
579
if TESTAMENT . branch_name . is_some ( ) {
580
580
writeln ! (
581
- process ( ) . stdout( ) . lock( ) ,
581
+ Process :: get ( ) . stdout( ) . lock( ) ,
582
582
"Built from branch: {}" ,
583
583
TESTAMENT . branch_name. unwrap( )
584
584
) ?;
585
585
} else {
586
- writeln ! ( process ( ) . stdout( ) . lock( ) , "Branch information missing" ) ?;
586
+ writeln ! ( Process :: get ( ) . stdout( ) . lock( ) , "Branch information missing" ) ?;
587
587
}
588
588
writeln ! (
589
- process ( ) . stdout( ) . lock( ) ,
589
+ Process :: get ( ) . stdout( ) . lock( ) ,
590
590
"Commit info: {}" ,
591
591
TESTAMENT . commit
592
592
) ?;
593
593
if TESTAMENT . modifications . is_empty ( ) {
594
- writeln ! ( process ( ) . stdout( ) . lock( ) , "Working tree is clean" ) ?;
594
+ writeln ! ( Process :: get ( ) . stdout( ) . lock( ) , "Working tree is clean" ) ?;
595
595
} else {
596
596
for fmod in TESTAMENT . modifications {
597
597
match fmod {
598
598
Added ( f) => writeln ! (
599
- process ( ) . stdout( ) . lock( ) ,
599
+ Process :: get ( ) . stdout( ) . lock( ) ,
600
600
"Added: {}" ,
601
601
String :: from_utf8_lossy( f)
602
602
) ?,
603
603
Removed ( f) => writeln ! (
604
- process ( ) . stdout( ) . lock( ) ,
604
+ Process :: get ( ) . stdout( ) . lock( ) ,
605
605
"Removed: {}" ,
606
606
String :: from_utf8_lossy( f)
607
607
) ?,
608
608
Modified ( f) => writeln ! (
609
- process ( ) . stdout( ) . lock( ) ,
609
+ Process :: get ( ) . stdout( ) . lock( ) ,
610
610
"Modified: {}" ,
611
611
String :: from_utf8_lossy( f)
612
612
) ?,
613
613
Untracked ( f) => writeln ! (
614
- process ( ) . stdout( ) . lock( ) ,
614
+ Process :: get ( ) . stdout( ) . lock( ) ,
615
615
"Untracked: {}" ,
616
616
String :: from_utf8_lossy( f)
617
617
) ?,
@@ -622,15 +622,15 @@ pub(crate) fn dump_testament() -> Result<utils::ExitCode> {
622
622
}
623
623
624
624
fn show_backtrace ( ) -> bool {
625
- if let Ok ( true ) = process ( ) . var ( "RUSTUP_NO_BACKTRACE" ) . map ( |s| s == "1" ) {
625
+ if let Ok ( true ) = Process :: get ( ) . var ( "RUSTUP_NO_BACKTRACE" ) . map ( |s| s == "1" ) {
626
626
return false ;
627
627
}
628
628
629
- if let Ok ( true ) = process ( ) . var ( "RUST_BACKTRACE" ) . map ( |s| s == "1" ) {
629
+ if let Ok ( true ) = Process :: get ( ) . var ( "RUST_BACKTRACE" ) . map ( |s| s == "1" ) {
630
630
return true ;
631
631
}
632
632
633
- for arg in process ( ) . args ( ) {
633
+ for arg in Process :: get ( ) . args ( ) {
634
634
if arg == "-v" || arg == "--verbose" {
635
635
return true ;
636
636
}
0 commit comments