mirror of
https://github.com/Orange-OpenSource/hurl.git
synced 2024-12-25 03:52:09 +03:00
Fix --in-place option for hurlfmt
This commit is contained in:
parent
9d0a57b9fb
commit
a3b6947eb7
@ -55,7 +55,7 @@ pub fn in_place() -> clap::Arg {
|
||||
}
|
||||
|
||||
pub fn input_file() -> clap::Arg {
|
||||
clap::Arg::new("INPUT")
|
||||
clap::Arg::new("input_file")
|
||||
.help("Sets the input file to use")
|
||||
.required(false)
|
||||
.index(1)
|
||||
|
@ -83,7 +83,7 @@ pub fn in_place(arg_matches: &ArgMatches) -> Result<bool, OptionsError> {
|
||||
}
|
||||
|
||||
pub fn input_file(arg_matches: &ArgMatches) -> Result<Option<PathBuf>, OptionsError> {
|
||||
match get_string(arg_matches, "INPUT") {
|
||||
match get_string(arg_matches, "input_file") {
|
||||
None => Ok(None),
|
||||
Some(s) => {
|
||||
let path = Path::new(&s);
|
||||
|
@ -48,7 +48,6 @@ fn main() {
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
init_colored();
|
||||
|
||||
let log_error_message = cli::make_logger_error_message(opts.color);
|
||||
@ -128,7 +127,20 @@ fn main() {
|
||||
} else {
|
||||
output
|
||||
};
|
||||
write_output(output.into_bytes(), opts.output_file);
|
||||
let output_file = match opts.output_file {
|
||||
None => {
|
||||
if opts.in_place {
|
||||
Some(
|
||||
opts.input_file
|
||||
.expect("an input file when --in-place is set"),
|
||||
)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
v => v,
|
||||
};
|
||||
write_output(output.into_bytes(), output_file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user