Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 17 additions & 8 deletions server/src/option.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,22 +45,21 @@ pub struct Config<S>
where
S: Clone + clap::Args + StorageOpt,
{
pub parseable: Opt<S>,
pub parseable: Server<S>,
}

impl<S> Config<S>
where
S: Clone + clap::Args + StorageOpt,
{
fn new() -> Self {
let parseable = match Opt::<S>::try_parse() {
let Cli::Server::<S>(args) = match Cli::<S>::try_parse() {
Ok(s) => s,
Err(e) => {
eprintln!("You can also use the --demo flag to run Parseable with default object storage. For testing purposes only");
e.exit();
}
};
Config { parseable }
Config { parseable: args }
}

pub fn storage(&self) -> &S {
Expand Down Expand Up @@ -148,13 +147,23 @@ where
}
}

#[derive(Debug, Clone, Parser)]
#[derive(Parser)] // requires `derive` feature
#[command(
name = "Parseable",
about = "Configuration for Parseable server",
bin_name = "parseable",
about = "Parseable is a log storage and observability platform.",
version
)]
pub struct Opt<S>
enum Cli<S>
where
S: Clone + clap::Args + StorageOpt,
{
Server(Server<S>),
}

#[derive(clap::Args, Debug, Clone)]
#[clap(name = "server", about = "Start the Parseable server")]
pub struct Server<S>
where
S: Clone + clap::Args + StorageOpt,
{
Expand Down Expand Up @@ -222,7 +231,7 @@ where
pub demo: bool,
}

impl<S> Opt<S>
impl<S> Server<S>
where
S: Clone + clap::Args + StorageOpt,
{
Expand Down