Skip to content

Commit

Permalink
other/dummy: use clap to manage args
Browse files Browse the repository at this point in the history
  • Loading branch information
Mingshen Sun committed Sep 1, 2018
1 parent 7f7ddb8 commit 076dbb2
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions libmesabox/src/other/dummy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
// For a copy, see the LICENSE file.
//

use {UtilSetup, ArgsIter, Result, UtilRead, UtilWrite};
use clap::{App, Arg, ArgMatches};
use std::io::{self, Write};
use {UtilSetup, ArgsIter, Result, UtilRead, UtilWrite};

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

Expand Down Expand Up @@ -40,13 +41,25 @@ where
}
}

pub fn execute<S, T>(setup: &mut S, _args: T) -> Result<()>
fn create_app() -> App<'static, 'static> {
util_app!("dummy")
.arg(Arg::with_name("about")
.short("a")
.long("about")
.help("show about"))
}

pub fn execute<S, T>(setup: &mut S, args: T) -> Result<()>
where
S: UtilSetup,
T: ArgsIter,
{
let app = create_app();
let matches = app.get_matches_from_safe(args)?;

let output = setup.output();
let mut output = output.lock()?;

let mut dummyer = Dummyer::new(output);
dummyer.dummy()?;
Ok(())
Expand Down

0 comments on commit 076dbb2

Please sign in to comment.