Create labadoor-auth
, for wrapping storage backends
This commit is contained in:
parent
104d8a862d
commit
5013fdcf1c
7 changed files with 58 additions and 0 deletions
|
@ -5,5 +5,6 @@ members = [
|
|||
"labadoor-telegram",
|
||||
"labadoor-csv",
|
||||
"labadoor",
|
||||
"labadoor-auth",
|
||||
"labadoor-acl",
|
||||
]
|
||||
|
|
11
labadoor-auth/Cargo.toml
Normal file
11
labadoor-auth/Cargo.toml
Normal file
|
@ -0,0 +1,11 @@
|
|||
[package]
|
||||
name = "labadoor-auth"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
clap = { version = "4.4.8", features = ["derive"] }
|
||||
labadoor-csv = { path = "../labadoor-csv", optional = true }
|
||||
|
||||
[features]
|
||||
csv = ["dep:labadoor-csv"]
|
31
labadoor-auth/src/cli.rs
Normal file
31
labadoor-auth/src/cli.rs
Normal file
|
@ -0,0 +1,31 @@
|
|||
use clap::{Parser, ValueEnum};
|
||||
|
||||
#[derive(Parser, Debug)]
|
||||
pub struct Cli {
|
||||
#[command(subcommand)]
|
||||
pub command: Command,
|
||||
#[arg(short, long, value_enum)]
|
||||
pub backend: Backend,
|
||||
}
|
||||
|
||||
#[derive(Parser, ValueEnum, Clone, Debug)]
|
||||
pub enum Backend {
|
||||
#[cfg(feature = "csv")]
|
||||
CSV,
|
||||
}
|
||||
|
||||
#[derive(Parser, Debug)]
|
||||
pub enum Command {
|
||||
Open(Open),
|
||||
}
|
||||
|
||||
#[derive(Parser, Debug)]
|
||||
pub struct Open {
|
||||
pub method: String,
|
||||
pub identifier: String,
|
||||
pub resource: i8,
|
||||
}
|
||||
|
||||
pub fn parse() -> Cli {
|
||||
Cli::parse()
|
||||
}
|
7
labadoor-auth/src/lib.rs
Normal file
7
labadoor-auth/src/lib.rs
Normal file
|
@ -0,0 +1,7 @@
|
|||
pub mod cli;
|
||||
|
||||
pub fn auth(i: &cli::Cli) {
|
||||
match i.command {
|
||||
cli::Command::Open(_) => todo!(),
|
||||
};
|
||||
}
|
|
@ -9,6 +9,7 @@ labadoor-telegram = { path = "../labadoor-telegram", optional = true }
|
|||
labadoor-matrix = { path = "../labadoor-matrix", optional = true }
|
||||
labadoor-csv = { path = "../labadoor-csv", optional = true }
|
||||
labadoor-gpio = { path = "../labadoor-gpio", optional = true }
|
||||
labadoor-auth = { path = "../labadoor-auth", optional = true }
|
||||
labadoor-acl = { path = "../labadoor-acl" }
|
||||
serde = { version = "1.0.164", features = ["derive"] }
|
||||
config = "0.13.3"
|
||||
|
@ -18,3 +19,4 @@ telegram = ["dep:labadoor-telegram"]
|
|||
matrix = ["dep:labadoor-matrix"]
|
||||
csv = ["dep:labadoor-csv"]
|
||||
gpio = ["dep:labadoor-gpio"]
|
||||
auth = ["dep:labadoor-auth"]
|
||||
|
|
|
@ -17,6 +17,8 @@ pub enum Command {
|
|||
CSV(CSV),
|
||||
#[cfg(feature = "gpio")]
|
||||
GPIO(GPIO),
|
||||
#[cfg(feature = "auth")]
|
||||
Auth(labadoor_auth::cli::Cli),
|
||||
}
|
||||
|
||||
#[cfg(feature = "telegram")]
|
||||
|
|
|
@ -34,5 +34,9 @@ fn main() {
|
|||
let gpio = config.get::<cli::GPIO>("gpio").unwrap().to_config();
|
||||
labadoor_gpio::gpio(gpio);
|
||||
}
|
||||
#[cfg(feature = "auth")]
|
||||
cli::Command::Auth(cli) => {
|
||||
labadoor_auth::auth(cli);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue