mod client;
mod server;
use crate::{
commands::{client::ClientCmd, server::ServerCmd},
config::RusticSchedulerConfig,
};
use abscissa_core::{Command, Configurable, FrameworkError, Runnable};
use std::path::PathBuf;
pub const CONFIG_FILE: &str = "rustic_scheduler.toml";
#[derive(clap::Parser, Command, Debug, Runnable)]
pub enum RusticSchedulerCmd {
Client(ClientCmd),
Server(ServerCmd),
}
#[derive(clap::Parser, Command, Debug)]
#[command(author, about, version)]
pub struct EntryPoint {
#[command(subcommand)]
cmd: RusticSchedulerCmd,
#[arg(short, long)]
pub verbose: bool,
#[arg(short, long)]
pub config: Option<String>,
}
impl Runnable for EntryPoint {
fn run(&self) {
self.cmd.run()
}
}
impl Configurable<RusticSchedulerConfig> for EntryPoint {
fn config_path(&self) -> Option<PathBuf> {
let filename = self
.config
.as_ref()
.map(PathBuf::from)
.unwrap_or_else(|| CONFIG_FILE.into());
if filename.exists() {
Some(filename)
} else {
None
}
}
fn process_config(
&self,
config: RusticSchedulerConfig,
) -> Result<RusticSchedulerConfig, FrameworkError> {
Ok(config)
}
}