Repository: sharkdp/fd
File: src/main.rs (Rust)

Code before:
use globset::Glob;
use lscolors::LsColors;
use regex::bytes::{RegexBuilder, RegexSetBuilder};

use crate::exec::CommandTemplate;
use crate::internal::{
    filter::{SizeFilter, TimeFilter},
    opts::FdOptions,
    pattern_has_uppercase_char, transform_args_with_exec, FileTypes,
};

// We use jemalloc for performance reasons, see https://github.com/sharkdp/fd/pull/481
#[cfg(all(not(windows), not(target_env = "musl")))]
#[global_allocator]
static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc;

fn main() {
    let checked_args = transform_args_with_exec(env::args_os());
    let matches = app::build_app().get_matches_from(checked_args);

    // Set the current working directory of the process
    if let Some(base_directory) = matches.value_of("base-directory") {
        let basedir = Path::new(base_directory);
        if !fshelper::is_dir(basedir) {
            print_error_and_exit!(
                "'{}' passed as '--base-directory' value is not a directory.",
                basedir.to_string_lossy()
            );
        }
        if let Err(e) = env::set_current_dir(basedir) {
            print_error_and_exit!(
                "Cannot set '{}' as current working directory: {}", 
                basedir.to_string_lossy(), e
            );
        }
    }

    // Get the search pattern
    let pattern = matches.value_of("pattern").unwrap_or("");

    // Get the current working directory
    let current_dir = Path::new(".");
    if !fshelper::is_dir(current_dir) {
        print_error_and_exit!("Could not get current directory.");
    }

    // Get one or more root directories to search.
    let mut dir_vec: Vec<_> = match matches
        .values_of("path")
        .or_else(|| matches.values_of("search-path"))
    {

Review comment (suggestion):
Maybe:
```
The '--base-directory' path ('{}') is not a directory.
```

Code after:
use globset::Glob;
use lscolors::LsColors;
use regex::bytes::{RegexBuilder, RegexSetBuilder};

use crate::exec::CommandTemplate;
use crate::internal::{
    filter::{SizeFilter, TimeFilter},
    opts::FdOptions,
    pattern_has_uppercase_char, transform_args_with_exec, FileTypes,
};

// We use jemalloc for performance reasons, see https://github.com/sharkdp/fd/pull/481
#[cfg(all(not(windows), not(target_env = "musl")))]
#[global_allocator]
static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc;

fn main() {
    let checked_args = transform_args_with_exec(env::args_os());
    let matches = app::build_app().get_matches_from(checked_args);

    // Set the current working directory of the process
    if let Some(base_directory) = matches.value_of("base-directory") {
        let basedir = Path::new(base_directory);
        if !fshelper::is_dir(basedir) {
            print_error_and_exit!(
                "The '--base-directory' path ('{}') is not a directory.",
                basedir.to_string_lossy()
            );
        }
        if let Err(e) = env::set_current_dir(basedir) {
            print_error_and_exit!(
                "Could not set '{}' as the current working directory: {}", 
                basedir.to_string_lossy(), e
            );
        }
    }

    // Get the search pattern
    let pattern = matches.value_of("pattern").unwrap_or("");

    // Get the current working directory
    let current_dir = Path::new(".");
    if !fshelper::is_dir(current_dir) {
        print_error_and_exit!("Could not get current directory.");
    }

    // Get one or more root directories to search.
    let mut dir_vec: Vec<_> = match matches
        .values_of("path")
        .or_else(|| matches.values_of("search-path"))
    {