Repository: sharkdp/hyperfine
File: src/options.rs (Rust)

Code before:
                        return Err(OptionsError::UnknownOutputPolicy(arg.to_string()));
                    }
                    CommandOutputPolicy::File(path)
                }
            }
        } else {
            CommandOutputPolicy::Null
        };

        options.output_style = match matches.value_of("style") {
            Some("full") => OutputStyleOption::Full,
            Some("basic") => OutputStyleOption::Basic,
            Some("nocolor") => OutputStyleOption::NoColor,
            Some("color") => OutputStyleOption::Color,
            Some("none") => OutputStyleOption::Disabled,
            _ => {
                if options.command_output_policy == CommandOutputPolicy::Inherit
                    || !atty::is(Stream::Stdout)
                {
                    OutputStyleOption::Basic
                } else {
                    OutputStyleOption::Full
                }
            }
        };

        match options.output_style {
            OutputStyleOption::Basic | OutputStyleOption::NoColor => {
                colored::control::set_override(false)
            }
            OutputStyleOption::Full | OutputStyleOption::Color => {
                colored::control::set_override(true)
            }
            OutputStyleOption::Disabled => {}
        };

        options.executor_kind = if matches.is_present("no-shell") {
            ExecutorKind::Raw
        } else {
            match (matches.is_present("debug-mode"), matches.value_of("shell")) {
                (false, Some(shell)) if shell == "default" => ExecutorKind::Shell(Shell::default()),
                (false, Some(shell)) if shell == "none" => ExecutorKind::Raw,
                (false, Some(shell)) => ExecutorKind::Shell(Shell::parse_from_str(shell)?),
                (false, None) => ExecutorKind::Shell(Shell::default()),
                (true, Some(shell)) => ExecutorKind::Mock(Some(shell.into())),
                (true, None) => ExecutorKind::Mock(None),
            }
        };

        if matches.is_present("ignore-failure") {
            options.command_failure_action = CmdFailureAction::Ignore;

Review comment (suggestion):
I think the following would be a bit easier to read compared to the double-negation above, what do you think?

```suggestion
                } else if (env::var_os("TERM")
                    .map(|t| t == "unknown" || t == "dumb")
                    .unwrap_or(true)
                    || env::var_os("NO_COLOR")
                        .map(|t| !t.is_empty())
                        .unwrap_or(false))
```

Code after:
                        return Err(OptionsError::UnknownOutputPolicy(arg.to_string()));
                    }
                    CommandOutputPolicy::File(path)
                }
            }
        } else {
            CommandOutputPolicy::Null
        };

        options.output_style = match matches.value_of("style") {
            Some("full") => OutputStyleOption::Full,
            Some("basic") => OutputStyleOption::Basic,
            Some("nocolor") => OutputStyleOption::NoColor,
            Some("color") => OutputStyleOption::Color,
            Some("none") => OutputStyleOption::Disabled,
            _ => {
                if options.command_output_policy == CommandOutputPolicy::Inherit
                    || !atty::is(Stream::Stdout)
                {
                    OutputStyleOption::Basic
                } else if !(env::var_os("TERM")
                    .map(|t| t != "unknown" && t != "dumb")
                    .unwrap_or(false)
                    && env::var_os("NO_COLOR")
                        .map(|t| t.is_empty())
                        .unwrap_or(true))
                {
                    OutputStyleOption::NoColor
                } else {
                    OutputStyleOption::Full
                }
            }
        };

        match options.output_style {
            OutputStyleOption::Basic | OutputStyleOption::NoColor => {
                colored::control::set_override(false)
            }
            OutputStyleOption::Full | OutputStyleOption::Color => {
                colored::control::set_override(true)
            }
            OutputStyleOption::Disabled => {}
        };

        options.executor_kind = if matches.is_present("no-shell") {
            ExecutorKind::Raw
        } else {
            match (matches.is_present("debug-mode"), matches.value_of("shell")) {
                (false, Some(shell)) if shell == "default" => ExecutorKind::Shell(Shell::default()),
                (false, Some(shell)) if shell == "none" => ExecutorKind::Raw,
                (false, Some(shell)) => ExecutorKind::Shell(Shell::parse_from_str(shell)?),