Repository: casey/just
File: src/config.rs (Rust)

Code before:

    match value {
      arg::COLOR_AUTO => Ok(Color::auto()),
      arg::COLOR_ALWAYS => Ok(Color::always()),
      arg::COLOR_NEVER => Ok(Color::never()),
      _ => Err(ConfigError::Internal {
        message: format!("Invalid argument `{value}` to --color."),
      }),
    }
  }

  fn command_color_from_matches(matches: &ArgMatches) -> ConfigResult<Option<Colour>> {
    let value = matches
      .value_of(arg::COMMAND_COLOR)
      .ok_or_else(|| ConfigError::Internal {
        message: "`--command-color` had no value".to_string(),
      })?;

    match value {
      arg::COMMAND_COLOR_NONE => Ok(None),
      arg::COMMAND_COLOR_CYAN => Ok(Some(Colour::Cyan)),
      arg::COMMAND_COLOR_PURPLE => Ok(Some(Colour::Purple)),
      _ => Err(ConfigError::Internal {
        message: format!("Invalid argument `{value}` to --command-color."),
      }),
    }
  }

  fn dump_format_from_matches(matches: &ArgMatches) -> ConfigResult<DumpFormat> {
    let value = matches
      .value_of(arg::DUMP_FORMAT)
      .ok_or_else(|| ConfigError::Internal {
        message: "`--dump-format` had no value".to_string(),
      })?;

    match value {
      arg::DUMP_FORMAT_JSON => Ok(DumpFormat::Json),
      arg::DUMP_FORMAT_JUST => Ok(DumpFormat::Just),
      _ => Err(ConfigError::Internal {
        message: format!("Invalid argument `{value}` to --dump-format."),
      }),
    }
  }

  pub(crate) fn from_matches(matches: &ArgMatches) -> ConfigResult<Self> {
    let invocation_directory = env::current_dir().context(config_error::CurrentDirContext)?;

    let verbosity = if matches.is_present(arg::QUIET) {
      Verbosity::Quiet
    } else {
      Verbosity::from_flag_occurrences(matches.occurrences_of(arg::VERBOSE))

Review comment (suggestion):
```suggestion
    match matches.value_of(arg::COMMAND_COLOR)? {
      arg::COMMAND_COLOR_CYAN => Ok(Some(ansi_term::Color::Cyan)),
      arg::COMMAND_COLOR_PURPLE => Ok(Some(ansi_term::Color::Purple)),
      _ => Err(ConfigError::Internal {
        message: format!("Invalid argument `{value}` to --command-color."),
      }),
    }
```

Code after:
    }
  }

  fn color_from_matches(matches: &ArgMatches) -> ConfigResult<Color> {
    let value = matches
      .value_of(arg::COLOR)
      .ok_or_else(|| ConfigError::Internal {
        message: "`--color` had no value".to_string(),
      })?;

    match value {
      arg::COLOR_AUTO => Ok(Color::auto()),
      arg::COLOR_ALWAYS => Ok(Color::always()),
      arg::COLOR_NEVER => Ok(Color::never()),
      _ => Err(ConfigError::Internal {
        message: format!("Invalid argument `{value}` to --color."),
      }),
    }
  }

  fn command_color_from_matches(matches: &ArgMatches) -> ConfigResult<Option<ansi_term::Color>> {
    if let Some(value) = matches.value_of(arg::COMMAND_COLOR) {
      match value {
        arg::COMMAND_COLOR_BLACK => Ok(Some(ansi_term::Color::Black)),
        arg::COMMAND_COLOR_BLUE => Ok(Some(ansi_term::Color::Blue)),
        arg::COMMAND_COLOR_CYAN => Ok(Some(ansi_term::Color::Cyan)),
        arg::COMMAND_COLOR_GREEN => Ok(Some(ansi_term::Color::Green)),
        arg::COMMAND_COLOR_PURPLE => Ok(Some(ansi_term::Color::Purple)),
        arg::COMMAND_COLOR_RED => Ok(Some(ansi_term::Color::Red)),
        arg::COMMAND_COLOR_YELLOW => Ok(Some(ansi_term::Color::Yellow)),
        value => Err(ConfigError::Internal {
          message: format!("Invalid argument `{value}` to --command-color."),
        }),
      }
    } else {
      Ok(None)
    }
  }

  fn dump_format_from_matches(matches: &ArgMatches) -> ConfigResult<DumpFormat> {
    let value = matches
      .value_of(arg::DUMP_FORMAT)
      .ok_or_else(|| ConfigError::Internal {
        message: "`--dump-format` had no value".to_string(),
      })?;

    match value {
      arg::DUMP_FORMAT_JSON => Ok(DumpFormat::Json),
      arg::DUMP_FORMAT_JUST => Ok(DumpFormat::Just),
      _ => Err(ConfigError::Internal {
        message: format!("Invalid argument `{value}` to --dump-format."),