Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use clap; // 2.33.0
- use clap::{App, Arg, ArgMatches};
- pub struct UI;
- impl UI {
- pub fn populate_cli_args(app: clap::App<'static, 'static>) -> clap::App<'static, 'static> {
- app.arg(
- Arg::with_name("config")
- .short("c")
- .long("config")
- .value_name("FILE")
- .help("Sets a custom config file")
- .takes_value(true)
- )
- }
- }
- pub struct FileHandler;
- impl FileHandler {
- pub fn populate_cli_args(app: clap::App<'static, 'static>) -> clap::App<'static, 'static> {
- app.arg(
- Arg::with_name("config")
- .short("c")
- .long("config")
- .value_name("FILE")
- .help("Sets a custom config file")
- .takes_value(true)
- )
- }
- }
- fn main() {
- let mut app = clap::App::new("My super program");
- app = UI::populate_cli_args(app);
- app = FileHandler::populate_cli_args(app);
- let matches = app.get_matches();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement