1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
use crate::context::Context;
use crate::repl::{Error, Subcommand};
use reedline_repl_rs::clap::{Arg, ArgMatches, Command};
use reedline_repl_rs::Repl;
#[allow(clippy::unused_async)]
async fn run(matches: ArgMatches, _context: &mut Context) -> Result<Option<String>, Error> {
let _key = matches
.value_of("key")
.expect("Required value validated by clap")
.to_owned();
Ok(None)
}
impl Subcommand for ThisCommand {
fn name(&self) -> &str {
"get"
}
fn build_command(&self, repl: Repl<Context, Error>) -> Repl<Context, Error> {
repl.with_command_async(
Command::new(self.name()).about("get setting by key").arg(
Arg::new("key")
.required(true)
.help("dotted path to setting"),
),
|args, context| Box::pin(run(args, context)),
)
}
}
struct ThisCommand {}
pub fn build() -> Box<dyn Subcommand> {
Box::new(ThisCommand {})
}