Skip to content

[BUG] xdiff get_default_config return err when no default file #1

@shichaoyuan

Description

@shichaoyuan

let config_file = args.config.unwrap_or(get_default_config("xdiff.yml")?);

async fn run(output: &mut Vec<String>, args: RunArgs) -> Result<()> {
    let config_file = args.config.unwrap_or(get_default_config("xdiff.yml")?);
    let diff_config = DiffConfig::try_load(&config_file).await?;

当没有默认配置文件时,get_default_config("xdiff.yml")? 会直接返回错误。

我理解这里的逻辑应该是:

  1. 首先看用户是否指定了配置 args.config
  2. 如果用户没有指定再尝试获取 default_config
  3. 如果还没有才返回 Err

这里可能需要用 unwrap_or_else 而不是 unwrap_or。

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions