8 changed files with 110 additions and 99 deletions
@ -1,17 +1,49 @@
|
||||
use super::defaults; |
||||
use clap::Parser; |
||||
use clap::{Args as ClapArgs, Parser, Subcommand}; |
||||
use std::path::PathBuf; |
||||
|
||||
#[derive(Parser, Debug)] |
||||
#[command(author, version, about)] |
||||
pub struct Args { |
||||
#[command(flatten)] |
||||
pub global: GlobalArgs, |
||||
|
||||
#[command(subcommand)] |
||||
pub command: Command, |
||||
} |
||||
|
||||
#[derive(ClapArgs, Debug)] |
||||
pub struct GlobalArgs { |
||||
/// Path to config file
|
||||
#[arg(short, long, default_value = "config.toml")] |
||||
pub config: PathBuf, |
||||
|
||||
#[arg(long, help = defaults::HELP_LOG)] |
||||
pub log_level: Option<String>, |
||||
} |
||||
|
||||
#[derive(Subcommand, Debug, Clone)] |
||||
pub enum Command { |
||||
/// Start the application server
|
||||
Server(ServerArgs), |
||||
|
||||
/// Export dictionary to file
|
||||
ExportDict(ExportDictArgs), |
||||
} |
||||
|
||||
#[derive(ClapArgs, Debug, Clone)] |
||||
pub struct ServerArgs { |
||||
#[arg(short, long, help = defaults::HELP_PORT)] |
||||
pub port: Option<u16>, |
||||
} |
||||
|
||||
#[arg(long, help = defaults::HELP_LOG)] |
||||
pub log_level: Option<String>, |
||||
#[derive(ClapArgs, Debug, Clone)] |
||||
pub struct ExportDictArgs { |
||||
/// Name of the dictionary to export
|
||||
#[arg(long)] |
||||
pub name: String, |
||||
|
||||
/// Output file path
|
||||
#[arg(long)] |
||||
pub output: PathBuf, |
||||
} |
||||
|
||||
@ -0,0 +1,12 @@
|
||||
use crate::bootstrap::AppConfig; |
||||
use crate::bootstrap::cli::ExportDictArgs; |
||||
use crate::container::Container; |
||||
use tracing::info; |
||||
|
||||
pub async fn run(args: ExportDictArgs, _config: AppConfig, _container: Container) { |
||||
info!("Exporting dictionary '{}' to {:?}", args.name, args.output); |
||||
|
||||
// Logic for export would go here
|
||||
// e.g. let dict = container.dict_service.get(args.name);
|
||||
// encoder.write(dict, args.output);
|
||||
} |
||||
@ -0,0 +1,13 @@
|
||||
use crate::bootstrap::AppConfig; |
||||
use crate::container::Container; |
||||
use tracing::info; |
||||
|
||||
pub async fn run(config: AppConfig, container: Container) { |
||||
loop { |
||||
tokio::time::sleep(tokio::time::Duration::from_secs(5)).await; |
||||
info!("Health check... DB URL: {}", config.database.url); |
||||
|
||||
// Example usage of the container
|
||||
// let _ = container.user_service.do_something();
|
||||
} |
||||
} |
||||
Loading…
Reference in new issue