labadoor-csv: Integrate in main cli module

This commit is contained in:
George Kaklamanos 2023-09-17 19:54:48 +03:00
parent c8e412fa34
commit 58f9eec430
3 changed files with 25 additions and 8 deletions

View file

@ -14,7 +14,7 @@ pub enum Command {
#[cfg(feature = "matrix")]
Matrix(Matrix),
#[cfg(feature = "csv")]
CSV,
CSV(CSV),
#[cfg(feature = "gpio")]
GPIO(GPIO),
}
@ -35,6 +35,21 @@ pub struct Matrix {
pub password: Option<String>,
}
#[cfg(feature = "csv")]
#[derive(Deserialize, Parser, Debug)]
pub struct CSV {
#[clap(short, long)]
#[arg(default_value = "Some(String::from(\"/etc/labadoor\"))")]
pub path: Option<String>,
#[clap(short, long)]
pub method: String,
#[clap(short, long)]
pub identifier: String,
// #[cfg(feature = "multiple_resources")]
#[clap(short, long)]
pub resource_shortcut: i8,
}
#[cfg(feature = "gpio")]
#[derive(Deserialize, Parser, Debug)]
pub struct GPIO {

View file

@ -19,8 +19,14 @@ fn main() {
labadoor_matrix::matrix(matrix.username.unwrap(), matrix.password.unwrap());
}
#[cfg(feature = "csv")]
cli::Command::CSV => {
labadoor_csv::csv();
cli::Command::CSV(_) => {
let csv = config.get::<cli::CSV>("csv").unwrap();
labadoor_csv::csv(
csv.path.unwrap(),
csv.method.unwrap(),
csv.identifier.unwrap(),
csv.resource_shortcut.unwrap(),
);
}
#[cfg(feature = "gpio")]
cli::Command::GPIO(_) => {