@@ -25,14 +25,14 @@ use crate::utils::tty::{stderr_isatty, stdout_isatty};
25
25
/// Allows concrete types for the currentprocess abstraction.
26
26
#[ derive( Clone , Debug ) ]
27
27
pub enum Process {
28
- OSProcess ( OSProcess ) ,
28
+ Os ( OSProcess ) ,
29
29
#[ cfg( feature = "test" ) ]
30
- TestProcess ( TestProcess ) ,
30
+ Test ( TestProcess ) ,
31
31
}
32
32
33
33
impl Process {
34
34
pub fn os ( ) -> Self {
35
- Self :: OSProcess ( OSProcess :: new ( ) )
35
+ Self :: Os ( OSProcess :: new ( ) )
36
36
}
37
37
38
38
pub fn name ( & self ) -> Option < String > {
@@ -50,9 +50,9 @@ impl Process {
50
50
51
51
pub fn var ( & self , key : & str ) -> Result < String , env:: VarError > {
52
52
match self {
53
- Process :: OSProcess ( _) => env:: var ( key) ,
53
+ Process :: Os ( _) => env:: var ( key) ,
54
54
#[ cfg( feature = "test" ) ]
55
- Process :: TestProcess ( p) => match p. vars . get ( key) {
55
+ Process :: Test ( p) => match p. vars . get ( key) {
56
56
Some ( val) => Ok ( val. to_owned ( ) ) ,
57
57
None => Err ( env:: VarError :: NotPresent ) ,
58
58
} ,
@@ -61,100 +61,100 @@ impl Process {
61
61
62
62
pub ( crate ) fn var_os ( & self , key : & str ) -> Option < OsString > {
63
63
match self {
64
- Process :: OSProcess ( _) => env:: var_os ( key) ,
64
+ Process :: Os ( _) => env:: var_os ( key) ,
65
65
#[ cfg( feature = "test" ) ]
66
- Process :: TestProcess ( p) => p. vars . get ( key) . map ( OsString :: from) ,
66
+ Process :: Test ( p) => p. vars . get ( key) . map ( OsString :: from) ,
67
67
}
68
68
}
69
69
70
70
pub ( crate ) fn args ( & self ) -> Box < dyn Iterator < Item = String > + ' _ > {
71
71
match self {
72
- Process :: OSProcess ( _) => Box :: new ( env:: args ( ) ) ,
72
+ Process :: Os ( _) => Box :: new ( env:: args ( ) ) ,
73
73
#[ cfg( feature = "test" ) ]
74
- Process :: TestProcess ( p) => Box :: new ( p. args . iter ( ) . cloned ( ) ) ,
74
+ Process :: Test ( p) => Box :: new ( p. args . iter ( ) . cloned ( ) ) ,
75
75
}
76
76
}
77
77
78
78
pub ( crate ) fn args_os ( & self ) -> Box < dyn Iterator < Item = OsString > + ' _ > {
79
79
match self {
80
- Process :: OSProcess ( _) => Box :: new ( env:: args_os ( ) ) ,
80
+ Process :: Os ( _) => Box :: new ( env:: args_os ( ) ) ,
81
81
#[ cfg( feature = "test" ) ]
82
- Process :: TestProcess ( p) => Box :: new ( p. args . iter ( ) . map ( OsString :: from) ) ,
82
+ Process :: Test ( p) => Box :: new ( p. args . iter ( ) . map ( OsString :: from) ) ,
83
83
}
84
84
}
85
85
86
86
pub ( crate ) fn stdin ( & self ) -> Box < dyn filesource:: Stdin > {
87
87
match self {
88
- Process :: OSProcess ( _) => Box :: new ( io:: stdin ( ) ) ,
88
+ Process :: Os ( _) => Box :: new ( io:: stdin ( ) ) ,
89
89
#[ cfg( feature = "test" ) ]
90
- Process :: TestProcess ( p) => Box :: new ( filesource:: TestStdin ( p. stdin . clone ( ) ) ) ,
90
+ Process :: Test ( p) => Box :: new ( filesource:: TestStdin ( p. stdin . clone ( ) ) ) ,
91
91
}
92
92
}
93
93
94
94
pub ( crate ) fn stdout ( & self ) -> Box < dyn filesource:: Writer > {
95
95
match self {
96
- Process :: OSProcess ( _) => Box :: new ( io:: stdout ( ) ) ,
96
+ Process :: Os ( _) => Box :: new ( io:: stdout ( ) ) ,
97
97
#[ cfg( feature = "test" ) ]
98
- Process :: TestProcess ( p) => Box :: new ( filesource:: TestWriter ( p. stdout . clone ( ) ) ) ,
98
+ Process :: Test ( p) => Box :: new ( filesource:: TestWriter ( p. stdout . clone ( ) ) ) ,
99
99
}
100
100
}
101
101
102
102
pub ( crate ) fn stderr ( & self ) -> Box < dyn filesource:: Writer > {
103
103
match self {
104
- Process :: OSProcess ( _) => Box :: new ( io:: stderr ( ) ) ,
104
+ Process :: Os ( _) => Box :: new ( io:: stderr ( ) ) ,
105
105
#[ cfg( feature = "test" ) ]
106
- Process :: TestProcess ( p) => Box :: new ( filesource:: TestWriter ( p. stderr . clone ( ) ) ) ,
106
+ Process :: Test ( p) => Box :: new ( filesource:: TestWriter ( p. stderr . clone ( ) ) ) ,
107
107
}
108
108
}
109
109
110
110
pub ( crate ) fn current_dir ( & self ) -> io:: Result < PathBuf > {
111
111
match self {
112
- Process :: OSProcess ( _) => env:: current_dir ( ) ,
112
+ Process :: Os ( _) => env:: current_dir ( ) ,
113
113
#[ cfg( feature = "test" ) ]
114
- Process :: TestProcess ( p) => Ok ( p. cwd . clone ( ) ) ,
114
+ Process :: Test ( p) => Ok ( p. cwd . clone ( ) ) ,
115
115
}
116
116
}
117
117
118
118
#[ cfg( test) ]
119
119
fn id ( & self ) -> u64 {
120
120
match self {
121
- Process :: OSProcess ( _) => std:: process:: id ( ) as u64 ,
121
+ Process :: Os ( _) => std:: process:: id ( ) as u64 ,
122
122
#[ cfg( feature = "test" ) ]
123
- Process :: TestProcess ( p) => p. id ,
123
+ Process :: Test ( p) => p. id ,
124
124
}
125
125
}
126
126
}
127
127
128
128
impl home:: env:: Env for Process {
129
129
fn home_dir ( & self ) -> Option < PathBuf > {
130
130
match self {
131
- Process :: OSProcess ( _) => self . var ( "HOME" ) . ok ( ) . map ( |v| v. into ( ) ) ,
131
+ Process :: Os ( _) => self . var ( "HOME" ) . ok ( ) . map ( |v| v. into ( ) ) ,
132
132
#[ cfg( feature = "test" ) ]
133
- Process :: TestProcess ( _) => home:: env:: OS_ENV . home_dir ( ) ,
133
+ Process :: Test ( _) => home:: env:: OS_ENV . home_dir ( ) ,
134
134
}
135
135
}
136
136
137
137
fn current_dir ( & self ) -> Result < PathBuf , io:: Error > {
138
138
match self {
139
- Process :: OSProcess ( _) => self . current_dir ( ) ,
139
+ Process :: Os ( _) => self . current_dir ( ) ,
140
140
#[ cfg( feature = "test" ) ]
141
- Process :: TestProcess ( _) => home:: env:: OS_ENV . current_dir ( ) ,
141
+ Process :: Test ( _) => home:: env:: OS_ENV . current_dir ( ) ,
142
142
}
143
143
}
144
144
145
145
fn var_os ( & self , key : & str ) -> Option < OsString > {
146
146
match self {
147
- Process :: OSProcess ( _) => self . var_os ( key) ,
147
+ Process :: Os ( _) => self . var_os ( key) ,
148
148
#[ cfg( feature = "test" ) ]
149
- Process :: TestProcess ( _) => self . var_os ( key) ,
149
+ Process :: Test ( _) => self . var_os ( key) ,
150
150
}
151
151
}
152
152
}
153
153
154
154
#[ cfg( feature = "test" ) ]
155
155
impl From < TestProcess > for Process {
156
156
fn from ( p : TestProcess ) -> Self {
157
- Self :: TestProcess ( p)
157
+ Self :: Test ( p)
158
158
}
159
159
}
160
160
0 commit comments