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

Code before:
          env!("CARGO_PKG_DESCRIPTION"),
          " - ",
          env!("CARGO_PKG_HOMEPAGE")
        ))
    }
  }

  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_RED => Ok(Some(ansi_term::Color::Red)),
        arg::COMMAND_COLOR_GREEN => Ok(Some(ansi_term::Color::Green)),
        arg::COMMAND_COLOR_YELLOW => Ok(Some(ansi_term::Color::Yellow)),
        arg::COMMAND_COLOR_BLUE => Ok(Some(ansi_term::Color::Blue)),
        arg::COMMAND_COLOR_PURPLE => Ok(Some(ansi_term::Color::Purple)),
        arg::COMMAND_COLOR_CYAN => Ok(Some(ansi_term::Color::Cyan)),
        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 {

Review comment (suggestion):
I was getting a compile error with the `?` at the end of `matches.value_of(arg::COMMAND_COLOR)`. It said the `?` cannot be used on Options if the function returns a Result. 

Code after:
          env!("CARGO_PKG_DESCRIPTION"),
          " - ",
          env!("CARGO_PKG_HOMEPAGE")
        ))
    }
  }

  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 {