mirror of
https://github.com/Hopiu/lychee.git
synced 2026-04-18 04:10:57 +00:00
Always display output in the expected format
Even on stdout we print JSON now if `--format json` is set. The reason is that not outputting any JSON when the format is requested can be unintuitive. It is also great for debugging purposes before sending the output to a file with the `--output` argument.
This commit is contained in:
parent
0872604f18
commit
8e5799a041
1 changed files with 5 additions and 7 deletions
|
|
@ -16,7 +16,7 @@ use crate::options::{Config, LycheeOptions};
|
|||
use crate::stats::ResponseStats;
|
||||
|
||||
use lychee::collector::{self, Input};
|
||||
use lychee::{ClientBuilder, ClientPool, Response, Status};
|
||||
use lychee::{ClientBuilder, ClientPool, Response};
|
||||
|
||||
/// A C-like enum that can be cast to `i32` and used as process exit code.
|
||||
enum ExitCode {
|
||||
|
|
@ -169,13 +169,11 @@ async fn run(cfg: &Config, inputs: Vec<Input>) -> Result<i32> {
|
|||
pb.finish_and_clear();
|
||||
}
|
||||
|
||||
if cfg.verbose {
|
||||
println!("\n{}", stats);
|
||||
}
|
||||
|
||||
let stats_formatted = fmt(&stats, &cfg.format)?;
|
||||
if let Some(output) = &cfg.output {
|
||||
fs::write(output, fmt(&stats, &cfg.format)?)
|
||||
.context("Cannot write status output to file")?;
|
||||
fs::write(output, stats_formatted).context("Cannot write status output to file")?;
|
||||
} else {
|
||||
println!("\n{}", stats_formatted);
|
||||
}
|
||||
|
||||
match stats.is_success() {
|
||||
|
|
|
|||
Loading…
Reference in a new issue