pub mod certificate;
pub mod serve;
use std::path::{Path, PathBuf};
use structopt::StructOpt;
use crate::{Configuration, Server};
#[derive(StructOpt, Debug)]
pub struct Cli {
pub server_data_directory: PathBuf,
#[structopt(subcommand)]
pub subcommand: Command,
}
#[derive(StructOpt, Debug)]
pub enum Command {
Certificate(certificate::Command),
#[structopt(flatten)]
Serve(serve::Serve),
}
impl Command {
pub async fn execute<F: Fn(&Server) + Send>(
&self,
database_path: &Path,
schema_registrar: F,
) -> anyhow::Result<()> {
let server = Server::open(database_path, Configuration::default()).await?;
schema_registrar(&server);
match self {
Self::Certificate(command) => command.execute(server).await,
Self::Serve(command) => command.execute(server).await,
}
}
}