forked from gkaklas/labadoor
main: Fix warnings caused by conditional compilation
This commit is contained in:
parent
2c4ac96893
commit
8e0e311874
1 changed files with 14 additions and 2 deletions
|
@ -1,7 +1,12 @@
|
||||||
mod cli;
|
mod cli;
|
||||||
mod to_config;
|
mod to_config;
|
||||||
use to_config::ToConfig;
|
|
||||||
|
|
||||||
|
#[cfg(any(
|
||||||
|
feature = "telegram",
|
||||||
|
feature = "matrix",
|
||||||
|
feature = "gpio",
|
||||||
|
feature = "open"
|
||||||
|
))]
|
||||||
macro_rules! add_cliargs {
|
macro_rules! add_cliargs {
|
||||||
($d:ident,$section:expr,$i:ident) => {
|
($d:ident,$section:expr,$i:ident) => {
|
||||||
$d.add_source(config::File::from_str(
|
$d.add_source(config::File::from_str(
|
||||||
|
@ -16,7 +21,7 @@ macro_rules! add_cliargs {
|
||||||
use std::process::ExitCode;
|
use std::process::ExitCode;
|
||||||
fn main() -> ExitCode {
|
fn main() -> ExitCode {
|
||||||
let mut ret = ExitCode::SUCCESS;
|
let mut ret = ExitCode::SUCCESS;
|
||||||
let mut module_result: Result<(), ()> = Ok(());
|
let module_result: Result<(), ()>;
|
||||||
|
|
||||||
let cli = cli::parse();
|
let cli = cli::parse();
|
||||||
let config = config::Config::builder()
|
let config = config::Config::builder()
|
||||||
|
@ -25,24 +30,31 @@ fn main() -> ExitCode {
|
||||||
match &cli.command {
|
match &cli.command {
|
||||||
#[cfg(feature = "telegram")]
|
#[cfg(feature = "telegram")]
|
||||||
cli::Command::Telegram(cliargs) => {
|
cli::Command::Telegram(cliargs) => {
|
||||||
|
use to_config::ToConfig;
|
||||||
let config = add_cliargs!(config, "telegram", cliargs);
|
let config = add_cliargs!(config, "telegram", cliargs);
|
||||||
let telegram = config.get::<cli::Telegram>("telegram").unwrap().to_config();
|
let telegram = config.get::<cli::Telegram>("telegram").unwrap().to_config();
|
||||||
labadoor_telegram::telegram(telegram);
|
labadoor_telegram::telegram(telegram);
|
||||||
|
module_result = Ok(());
|
||||||
}
|
}
|
||||||
#[cfg(feature = "matrix")]
|
#[cfg(feature = "matrix")]
|
||||||
cli::Command::Matrix(cliargs) => {
|
cli::Command::Matrix(cliargs) => {
|
||||||
|
use to_config::ToConfig;
|
||||||
let config = add_cliargs!(config, "matrix", cliargs);
|
let config = add_cliargs!(config, "matrix", cliargs);
|
||||||
let matrix = config.get::<cli::Matrix>("matrix").unwrap().to_config();
|
let matrix = config.get::<cli::Matrix>("matrix").unwrap().to_config();
|
||||||
labadoor_matrix::matrix(matrix);
|
labadoor_matrix::matrix(matrix);
|
||||||
|
module_result = Ok(());
|
||||||
}
|
}
|
||||||
#[cfg(feature = "gpio")]
|
#[cfg(feature = "gpio")]
|
||||||
cli::Command::GPIO(cliargs) => {
|
cli::Command::GPIO(cliargs) => {
|
||||||
|
use to_config::ToConfig;
|
||||||
let config = add_cliargs!(config, "gpio", cliargs);
|
let config = add_cliargs!(config, "gpio", cliargs);
|
||||||
let gpio = config.get::<cli::GPIO>("gpio").unwrap().to_config();
|
let gpio = config.get::<cli::GPIO>("gpio").unwrap().to_config();
|
||||||
labadoor_gpio::gpio(gpio);
|
labadoor_gpio::gpio(gpio);
|
||||||
|
module_result = Ok(());
|
||||||
}
|
}
|
||||||
#[cfg(feature = "open")]
|
#[cfg(feature = "open")]
|
||||||
cli::Command::Open(cliargs) => {
|
cli::Command::Open(cliargs) => {
|
||||||
|
use to_config::ToConfig;
|
||||||
let config = add_cliargs!(config, "open", cliargs);
|
let config = add_cliargs!(config, "open", cliargs);
|
||||||
let open = config.get::<cli::Open>("open").unwrap().to_config();
|
let open = config.get::<cli::Open>("open").unwrap().to_config();
|
||||||
module_result = labadoor_open::open(open);
|
module_result = labadoor_open::open(open);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue