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

Silently ignore missing config file #223

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ extern crate duct;
extern crate lazy_static;
#[macro_use]
extern crate serde_derive;

#[macro_use]
mod output;

Expand Down Expand Up @@ -75,12 +76,14 @@ mod values;
mod duct_mock;

use clap::{Arg, Command as ClapCommand};
use std::io::ErrorKind::NotFound;

use std::path::PathBuf;

use crate::command_processor::CommandProcessor;
use crate::config::{ClickConfig, Config};
use crate::env::Env;
use crate::error::ClickError;

use crate::output::ClickWriter;

Expand Down Expand Up @@ -142,7 +145,14 @@ fn main() {
let click_conf = match ClickConfig::from_file(click_path.as_path().to_str().unwrap()) {
Ok(conf) => conf,
Err(e) => {
println!("Could not load click config: {e}\nUsing default values.");
match e {
ClickError::Io(e) => {
if e.kind() == NotFound {
// Silently ignore missing click config
}
}
_ => println!("Could not load click config: {e}\nUsing default values."),
};
ClickConfig::default()
}
};
Expand Down
Loading