log: Add structs for cli arguments and configuration

This commit is contained in:
George Kaklamanos 2023-11-30 20:49:13 +02:00
parent e32d6ce118
commit c078a13c8e
No known key found for this signature in database
GPG key ID: C0CAB8A6BDC9399D

42
labadoor-log/src/cli.rs Normal file
View file

@ -0,0 +1,42 @@
use clap::{Parser, ValueEnum};
use serde::{Deserialize, Serialize};
#[derive(Serialize, Parser, Debug)]
pub struct Cli {
#[command(subcommand)]
pub command: Command,
#[arg(short, long, value_enum)]
pub backends: Option<Vec<Backend>>,
}
#[derive(Serialize, Deserialize, Parser, ValueEnum, Clone, Debug)]
#[serde(rename_all = "lowercase")]
pub enum Backend {
#[cfg(feature = "csv")]
CSV,
}
#[derive(Serialize, Parser, Debug)]
pub enum Command {
Append(Append),
}
#[derive(Serialize, Parser, Debug)]
pub struct Append {
pub time: String,
pub username: String,
pub resource: String,
pub method: String,
}
pub fn parse() -> Cli {
Cli::parse()
}
#[cfg(feature = "csv")]
#[derive(Deserialize, Parser, Debug)]
pub struct CSV {
#[clap(short, long)]
#[arg(default_value = "Some(String::from(\"/etc/labadoor\"))")]
pub path: String,
}