Skip to content

Commit 076dbb2

Browse files
author
Mingshen Sun
committed
other/dummy: use clap to manage args
1 parent 7f7ddb8 commit 076dbb2

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

libmesabox/src/other/dummy.rs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66
// For a copy, see the LICENSE file.
77
//
88

9-
use {UtilSetup, ArgsIter, Result, UtilRead, UtilWrite};
9+
use clap::{App, Arg, ArgMatches};
1010
use std::io::{self, Write};
11+
use {UtilSetup, ArgsIter, Result, UtilRead, UtilWrite};
1112

1213
pub const DESCRIPTION: &str = "A dummy utility to demonstrate the framework";
1314

@@ -40,13 +41,25 @@ where
4041
}
4142
}
4243

43-
pub fn execute<S, T>(setup: &mut S, _args: T) -> Result<()>
44+
fn create_app() -> App<'static, 'static> {
45+
util_app!("dummy")
46+
.arg(Arg::with_name("about")
47+
.short("a")
48+
.long("about")
49+
.help("show about"))
50+
}
51+
52+
pub fn execute<S, T>(setup: &mut S, args: T) -> Result<()>
4453
where
4554
S: UtilSetup,
4655
T: ArgsIter,
4756
{
57+
let app = create_app();
58+
let matches = app.get_matches_from_safe(args)?;
59+
4860
let output = setup.output();
4961
let mut output = output.lock()?;
62+
5063
let mut dummyer = Dummyer::new(output);
5164
dummyer.dummy()?;
5265
Ok(())

0 commit comments

Comments
 (0)