Skip to content

Commit 224c235

Browse files
authored
Add a top level server command to Parseable (#168)
This ensures there is scope to add more commands later and also adheres to the standard practice.
1 parent c1825e6 commit 224c235

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

server/src/option.rs

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,22 +45,21 @@ pub struct Config<S>
4545
where
4646
S: Clone + clap::Args + StorageOpt,
4747
{
48-
pub parseable: Opt<S>,
48+
pub parseable: Server<S>,
4949
}
5050

5151
impl<S> Config<S>
5252
where
5353
S: Clone + clap::Args + StorageOpt,
5454
{
5555
fn new() -> Self {
56-
let parseable = match Opt::<S>::try_parse() {
56+
let Cli::Server::<S>(args) = match Cli::<S>::try_parse() {
5757
Ok(s) => s,
5858
Err(e) => {
59-
eprintln!("You can also use the --demo flag to run Parseable with default object storage. For testing purposes only");
6059
e.exit();
6160
}
6261
};
63-
Config { parseable }
62+
Config { parseable: args }
6463
}
6564

6665
pub fn storage(&self) -> &S {
@@ -148,13 +147,23 @@ where
148147
}
149148
}
150149

151-
#[derive(Debug, Clone, Parser)]
150+
#[derive(Parser)] // requires `derive` feature
152151
#[command(
153152
name = "Parseable",
154-
about = "Configuration for Parseable server",
153+
bin_name = "parseable",
154+
about = "Parseable is a log storage and observability platform.",
155155
version
156156
)]
157-
pub struct Opt<S>
157+
enum Cli<S>
158+
where
159+
S: Clone + clap::Args + StorageOpt,
160+
{
161+
Server(Server<S>),
162+
}
163+
164+
#[derive(clap::Args, Debug, Clone)]
165+
#[clap(name = "server", about = "Start the Parseable server")]
166+
pub struct Server<S>
158167
where
159168
S: Clone + clap::Args + StorageOpt,
160169
{
@@ -222,7 +231,7 @@ where
222231
pub demo: bool,
223232
}
224233

225-
impl<S> Opt<S>
234+
impl<S> Server<S>
226235
where
227236
S: Clone + clap::Args + StorageOpt,
228237
{

0 commit comments

Comments
 (0)