@@ -12,7 +12,7 @@ use core::prelude::*;
12
12
13
13
use core:: cell:: Cell ;
14
14
use core:: run;
15
- use core:: run:: ProgramOutput ;
15
+ use core:: run:: ProcessOutput ;
16
16
use core:: result:: Result ;
17
17
use extra:: getopts;
18
18
@@ -89,35 +89,35 @@ pub fn default_config(input_crate: &Path) -> Config {
89
89
}
90
90
}
91
91
92
- type Process = ~fn ( ( & str) , ( & [ ~str] ) ) -> ProgramOutput ;
92
+ type Process = ~fn ( ( & str) , ( & [ ~str] ) ) -> ProcessOutput ;
93
93
94
- pub fn mock_program_output ( _prog: & str, _args: & [ ~str] ) -> ProgramOutput {
95
- ProgramOutput {
94
+ pub fn mock_process_output ( _prog: & str, _args: & [ ~str] ) -> ProcessOutput {
95
+ ProcessOutput {
96
96
status : 0 ,
97
- out : ~"" ,
98
- err : ~""
97
+ output : ~[ ] ,
98
+ error : ~[ ]
99
99
}
100
100
}
101
101
102
- pub fn program_output ( prog: & str, args: & [ ~str] ) -> ProgramOutput {
103
- run : : program_output ( prog, args)
102
+ pub fn process_output ( prog: & str, args: & [ ~str] ) -> ProcessOutput {
103
+ run : : process_output ( prog, args)
104
104
}
105
105
106
106
pub fn parse_config( args: & [ ~str] ) -> Result < Config , ~str > {
107
- parse_config_( args, program_output )
107
+ parse_config_( args, process_output )
108
108
}
109
109
110
110
pub fn parse_config_(
111
111
args: & [ ~str] ,
112
- program_output : Process
112
+ process_output : Process
113
113
) -> Result < Config , ~str > {
114
114
let args = args. tail( ) ;
115
115
let opts = vec:: unzip( opts( ) ) . first( ) ;
116
116
match getopts:: getopts( args, opts) {
117
117
Ok ( matches) => {
118
118
if matches. free. len( ) == 1 {
119
119
let input_crate = Path ( * matches. free. head( ) ) ;
120
- config_from_opts( & input_crate, & matches, program_output )
120
+ config_from_opts( & input_crate, & matches, process_output )
121
121
} else if matches. free. is_empty( ) {
122
122
Err ( ~"no crates specified")
123
123
} else {
@@ -133,7 +133,7 @@ pub fn parse_config_(
133
133
fn config_from_opts(
134
134
input_crate: & Path ,
135
135
matches: & getopts:: Matches ,
136
- program_output : Process
136
+ process_output : Process
137
137
) -> Result < Config , ~str > {
138
138
139
139
let config = default_config( input_crate) ;
@@ -175,11 +175,11 @@ fn config_from_opts(
175
175
}
176
176
}
177
177
} ;
178
- let program_output = Cell ( program_output ) ;
178
+ let process_output = Cell ( process_output ) ;
179
179
let result = do result:: chain( result) |config| {
180
180
let pandoc_cmd = getopts:: opt_maybe_str( matches, opt_pandoc_cmd( ) ) ;
181
181
let pandoc_cmd = maybe_find_pandoc(
182
- & config, pandoc_cmd, program_output . take( ) ) ;
182
+ & config, pandoc_cmd, process_output . take( ) ) ;
183
183
do result:: chain( pandoc_cmd) |pandoc_cmd| {
184
184
result:: Ok ( Config {
185
185
pandoc_cmd : pandoc_cmd,
@@ -209,7 +209,7 @@ fn parse_output_style(output_style: &str) -> Result<OutputStyle, ~str> {
209
209
pub fn maybe_find_pandoc(
210
210
config: & Config ,
211
211
maybe_pandoc_cmd: Option < ~str > ,
212
- program_output : Process
212
+ process_output : Process
213
213
) -> Result < Option < ~str > , ~str > {
214
214
if config. output_format != PandocHtml {
215
215
return result:: Ok ( maybe_pandoc_cmd) ;
@@ -228,7 +228,7 @@ pub fn maybe_find_pandoc(
228
228
} ;
229
229
230
230
let pandoc = do vec:: find( possible_pandocs) |pandoc| {
231
- let output = program_output ( * pandoc, [ ~"--version"] ) ;
231
+ let output = process_output ( * pandoc, [ ~"--version"] ) ;
232
232
debug ! ( "testing pandoc cmd %s: %?" , * pandoc, output) ;
233
233
output. status == 0
234
234
} ;
@@ -244,10 +244,10 @@ pub fn maybe_find_pandoc(
244
244
mod test {
245
245
use core:: prelude : : * ;
246
246
use config:: * ;
247
- use core:: run:: ProgramOutput ;
247
+ use core:: run:: ProcessOutput ;
248
248
249
249
fn parse_config( args: & [ ~str] ) -> Result < Config , ~str > {
250
- parse_config_( args, mock_program_output )
250
+ parse_config_( args, mock_process_output )
251
251
}
252
252
253
253
#[ test]
@@ -256,10 +256,10 @@ mod test {
256
256
output_format : PandocHtml ,
257
257
.. default_config( & Path ( "test" ) )
258
258
} ;
259
- let mock_program_output : ~fn ( & str, & [ ~str] ) -> ProgramOutput = |_, _| {
260
- ProgramOutput { status : 0 , out : ~ "pandoc 1.8 . 2.1 ", err : ~"" }
259
+ let mock_process_output : ~fn ( & str, & [ ~str] ) -> ProcessOutput = |_, _| {
260
+ ProcessOutput { status : 0 , output : "pandoc 1.8.2.1" . to_bytes ( ) , error : ~[ ] }
261
261
} ;
262
- let result = maybe_find_pandoc( & config, None , mock_program_output ) ;
262
+ let result = maybe_find_pandoc( & config, None , mock_process_output ) ;
263
263
assert!( result == result:: Ok ( Some ( ~"pandoc")));
264
264
}
265
265
@@ -269,10 +269,10 @@ mod test {
269
269
output_format: PandocHtml,
270
270
.. default_config(&Path(" test"))
271
271
};
272
- let mock_program_output : ~fn(&str, &[~str]) -> ProgramOutput = |_, _| {
273
- ProgramOutput { status: 1, out : ~" ", err : ~" " }
272
+ let mock_process_output : ~fn(&str, &[~str]) -> ProcessOutput = |_, _| {
273
+ ProcessOutput { status: 1, output : ~[], error : ~[] }
274
274
};
275
- let result = maybe_find_pandoc(&config, None, mock_program_output );
275
+ let result = maybe_find_pandoc(&config, None, mock_process_output );
276
276
assert!(result == result::Err(~" couldn' t find pandoc"));
277
277
}
278
278
0 commit comments