Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
shichaoyuan opened this issue Sep 16, 2022 · 0 comments · May be fixed by #2
Open

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

shichaoyuan opened this issue Sep 16, 2022 · 0 comments · May be fixed by #2

Comments

@shichaoyuan
Copy link

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。

@daolanfler daolanfler linked a pull request Nov 22, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant