diff --git a/src/cli.rs b/src/cli.rs index 6fd05dd..c7112dd 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -1,9 +1,12 @@ +use clap::ValueHint; + #[derive(clap::Parser)] #[clap(author, version)] /// Pings configured hosts in a configurable intervals and exposes metrics for prometheus. pub struct Cli { /// Set config file - pub config: String, + #[clap(value_hint = ValueHint::FilePath)] + pub config: std::path::PathBuf, #[clap(short, long, parse(from_occurrences))] /// Be verbose (you can add this up to 4 times for more logs). /// By default, only errors are logged, so no output is a good thing. diff --git a/src/config.rs b/src/config.rs index 8ed18f0..874ed79 100644 --- a/src/config.rs +++ b/src/config.rs @@ -103,7 +103,7 @@ fn setup_fern(level: log::LevelFilter) { } } -fn read_config(path: &str) -> Result { +fn read_config(path: &std::path::Path) -> Result { let config_file_content = std::fs::read_to_string(path).context("Couldn't read config file")?; toml::from_str(&config_file_content).context("Couldn't parse config file") }