@@ -24,14 +24,14 @@ pub mod terminalsource;
24
24
/// Allows concrete types for the currentprocess abstraction.
25
25
#[ derive( Clone , Debug ) ]
26
26
pub enum Process {
27
- OSProcess ( OSProcess ) ,
27
+ OsProcess ( OsProcess ) ,
28
28
#[ cfg( feature = "test" ) ]
29
29
TestProcess ( TestContext ) ,
30
30
}
31
31
32
32
impl Process {
33
33
pub fn os ( ) -> Self {
34
- Self :: OSProcess ( OSProcess :: new ( ) )
34
+ Self :: OsProcess ( OsProcess :: new ( ) )
35
35
}
36
36
37
37
pub fn name ( & self ) -> Option < String > {
@@ -61,7 +61,7 @@ impl Process {
61
61
62
62
pub fn var ( & self , key : & str ) -> Result < String , env:: VarError > {
63
63
match self {
64
- Process :: OSProcess ( _) => env:: var ( key) ,
64
+ Process :: OsProcess ( _) => env:: var ( key) ,
65
65
#[ cfg( feature = "test" ) ]
66
66
Process :: TestProcess ( p) => match p. vars . get ( key) {
67
67
Some ( val) => Ok ( val. to_owned ( ) ) ,
@@ -72,55 +72,55 @@ impl Process {
72
72
73
73
pub ( crate ) fn var_os ( & self , key : & str ) -> Option < OsString > {
74
74
match self {
75
- Process :: OSProcess ( _) => env:: var_os ( key) ,
75
+ Process :: OsProcess ( _) => env:: var_os ( key) ,
76
76
#[ cfg( feature = "test" ) ]
77
77
Process :: TestProcess ( p) => p. vars . get ( key) . map ( OsString :: from) ,
78
78
}
79
79
}
80
80
81
81
pub ( crate ) fn args ( & self ) -> Box < dyn Iterator < Item = String > + ' _ > {
82
82
match self {
83
- Process :: OSProcess ( _) => Box :: new ( env:: args ( ) ) ,
83
+ Process :: OsProcess ( _) => Box :: new ( env:: args ( ) ) ,
84
84
#[ cfg( feature = "test" ) ]
85
85
Process :: TestProcess ( p) => Box :: new ( p. args . iter ( ) . cloned ( ) ) ,
86
86
}
87
87
}
88
88
89
89
pub ( crate ) fn args_os ( & self ) -> Box < dyn Iterator < Item = OsString > + ' _ > {
90
90
match self {
91
- Process :: OSProcess ( _) => Box :: new ( env:: args_os ( ) ) ,
91
+ Process :: OsProcess ( _) => Box :: new ( env:: args_os ( ) ) ,
92
92
#[ cfg( feature = "test" ) ]
93
93
Process :: TestProcess ( p) => Box :: new ( p. args . iter ( ) . map ( OsString :: from) ) ,
94
94
}
95
95
}
96
96
97
97
pub ( crate ) fn stdin ( & self ) -> Box < dyn filesource:: Stdin > {
98
98
match self {
99
- Process :: OSProcess ( _) => Box :: new ( io:: stdin ( ) ) ,
99
+ Process :: OsProcess ( _) => Box :: new ( io:: stdin ( ) ) ,
100
100
#[ cfg( feature = "test" ) ]
101
101
Process :: TestProcess ( p) => Box :: new ( filesource:: TestStdin ( p. stdin . clone ( ) ) ) ,
102
102
}
103
103
}
104
104
105
105
pub ( crate ) fn stdout ( & self ) -> Box < dyn filesource:: Writer > {
106
106
match self {
107
- Process :: OSProcess ( _) => Box :: new ( io:: stdout ( ) ) ,
107
+ Process :: OsProcess ( _) => Box :: new ( io:: stdout ( ) ) ,
108
108
#[ cfg( feature = "test" ) ]
109
109
Process :: TestProcess ( p) => Box :: new ( filesource:: TestWriter ( p. stdout . clone ( ) ) ) ,
110
110
}
111
111
}
112
112
113
113
pub ( crate ) fn stderr ( & self ) -> Box < dyn filesource:: Writer > {
114
114
match self {
115
- Process :: OSProcess ( _) => Box :: new ( io:: stderr ( ) ) ,
115
+ Process :: OsProcess ( _) => Box :: new ( io:: stderr ( ) ) ,
116
116
#[ cfg( feature = "test" ) ]
117
117
Process :: TestProcess ( p) => Box :: new ( filesource:: TestWriter ( p. stderr . clone ( ) ) ) ,
118
118
}
119
119
}
120
120
121
121
pub fn current_dir ( & self ) -> io:: Result < PathBuf > {
122
122
match self {
123
- Process :: OSProcess ( _) => env:: current_dir ( ) ,
123
+ Process :: OsProcess ( _) => env:: current_dir ( ) ,
124
124
#[ cfg( feature = "test" ) ]
125
125
Process :: TestProcess ( p) => Ok ( p. cwd . clone ( ) ) ,
126
126
}
@@ -130,15 +130,15 @@ impl Process {
130
130
impl home:: env:: Env for Process {
131
131
fn home_dir ( & self ) -> Option < PathBuf > {
132
132
match self {
133
- Process :: OSProcess ( _) => home:: env:: OS_ENV . home_dir ( ) ,
133
+ Process :: OsProcess ( _) => home:: env:: OS_ENV . home_dir ( ) ,
134
134
#[ cfg( feature = "test" ) ]
135
135
Process :: TestProcess ( _) => self . var ( "HOME" ) . ok ( ) . map ( |v| v. into ( ) ) ,
136
136
}
137
137
}
138
138
139
139
fn current_dir ( & self ) -> Result < PathBuf , io:: Error > {
140
140
match self {
141
- Process :: OSProcess ( _) => home:: env:: OS_ENV . current_dir ( ) ,
141
+ Process :: OsProcess ( _) => home:: env:: OS_ENV . current_dir ( ) ,
142
142
#[ cfg( feature = "test" ) ]
143
143
Process :: TestProcess ( _) => self . current_dir ( ) ,
144
144
}
@@ -152,23 +152,23 @@ impl home::env::Env for Process {
152
152
// ----------- real process -----------------
153
153
154
154
#[ derive( Clone , Debug ) ]
155
- pub struct OSProcess {
155
+ pub struct OsProcess {
156
156
pub ( self ) stderr_is_a_tty : bool ,
157
157
pub ( self ) stdout_is_a_tty : bool ,
158
158
}
159
159
160
- impl OSProcess {
160
+ impl OsProcess {
161
161
pub fn new ( ) -> Self {
162
- OSProcess {
162
+ OsProcess {
163
163
stderr_is_a_tty : io:: stderr ( ) . is_terminal ( ) ,
164
164
stdout_is_a_tty : io:: stdout ( ) . is_terminal ( ) ,
165
165
}
166
166
}
167
167
}
168
168
169
- impl Default for OSProcess {
169
+ impl Default for OsProcess {
170
170
fn default ( ) -> Self {
171
- OSProcess :: new ( )
171
+ OsProcess :: new ( )
172
172
}
173
173
}
174
174
0 commit comments