Skip to content

Commit

Permalink
Minor updates
Browse files Browse the repository at this point in the history
  • Loading branch information
sharkdp committed Dec 27, 2024
1 parent c65b298 commit 19198c2
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use std::path::PathBuf;
use clap::builder::ArgPredicate;
use clap::{ArgAction, Parser, ValueEnum};

use anyhow::{anyhow, Context, Result};
use anyhow::{anyhow, bail, Context, Result};

use const_format::formatcp;

Expand Down Expand Up @@ -235,10 +235,10 @@ fn run() -> Result<()> {

let mut reader = match opt.file {
Some(filename) => {
let file = File::open(&filename)?;
if file.metadata()?.is_dir() {
return Err(anyhow!("{} is a directory.", filename.display()));
if filename.is_dir() {
bail!("'{}' is a directory.", filename.to_string_lossy());
}
let file = File::open(&filename)?;

Input::File(file)
}
Expand Down

0 comments on commit 19198c2

Please sign in to comment.