feat: add subcommands cli, serve
This commit is contained in:
18
src/cli.rs
Normal file
18
src/cli.rs
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
use clap::{App, Arg, ArgMatches, SubCommand};
|
||||||
|
use rust_util::simple_error;
|
||||||
|
use rust_util::util_clap::{Command, CommandError};
|
||||||
|
|
||||||
|
pub struct CommandImpl;
|
||||||
|
|
||||||
|
impl Command for CommandImpl {
|
||||||
|
fn name(&self) -> &str { "cli" }
|
||||||
|
|
||||||
|
fn subcommand<'a>(&self) -> App<'a, 'a> {
|
||||||
|
SubCommand::with_name(self.name()).about("Local mini KMS cli")
|
||||||
|
.arg(Arg::with_name("connect").long("connect").takes_value(true).default_value("127.0.0.1:6567").help("Connect server"))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn run(&self, _arg_matches: &ArgMatches, sub_arg_matches: &ArgMatches) -> CommandError {
|
||||||
|
simple_error!("Not implemented")
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,6 +2,9 @@ use clap::{App, AppSettings, ArgMatches};
|
|||||||
use rust_util::{failure_and_exit, information};
|
use rust_util::{failure_and_exit, information};
|
||||||
use rust_util::util_clap::{Command, CommandError};
|
use rust_util::util_clap::{Command, CommandError};
|
||||||
|
|
||||||
|
mod cli;
|
||||||
|
mod serve;
|
||||||
|
|
||||||
pub struct DefaultCommandImpl;
|
pub struct DefaultCommandImpl;
|
||||||
|
|
||||||
impl DefaultCommandImpl {
|
impl DefaultCommandImpl {
|
||||||
@@ -21,7 +24,10 @@ fn main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn inner_main() -> CommandError {
|
fn inner_main() -> CommandError {
|
||||||
let commands: Vec<Box<dyn Command>> = vec![];
|
let commands: Vec<Box<dyn Command>> = vec![
|
||||||
|
Box::new(cli::CommandImpl),
|
||||||
|
Box::new(serve::CommandImpl),
|
||||||
|
];
|
||||||
let mut app = App::new(env!("CARGO_PKG_NAME"))
|
let mut app = App::new(env!("CARGO_PKG_NAME"))
|
||||||
.version(env!("CARGO_PKG_VERSION"))
|
.version(env!("CARGO_PKG_VERSION"))
|
||||||
.about(env!("CARGO_PKG_DESCRIPTION"))
|
.about(env!("CARGO_PKG_DESCRIPTION"))
|
||||||
|
|||||||
18
src/serve.rs
Normal file
18
src/serve.rs
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
use clap::{App, Arg, ArgMatches, SubCommand};
|
||||||
|
use rust_util::simple_error;
|
||||||
|
use rust_util::util_clap::{Command, CommandError};
|
||||||
|
|
||||||
|
pub struct CommandImpl;
|
||||||
|
|
||||||
|
impl Command for CommandImpl {
|
||||||
|
fn name(&self) -> &str { "serve" }
|
||||||
|
|
||||||
|
fn subcommand<'a>(&self) -> App<'a, 'a> {
|
||||||
|
SubCommand::with_name(self.name()).about("Local mini KMS serve")
|
||||||
|
.arg(Arg::with_name("listen").long("listen").takes_value(true).default_value("127.0.0.1:6567").help("Listen"))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn run(&self, _arg_matches: &ArgMatches, sub_arg_matches: &ArgMatches) -> CommandError {
|
||||||
|
simple_error!("Not implemented")
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user