Advertisement
Guest User

Untitled

a guest
Oct 18th, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. use clap; // 2.33.0
  2. use clap::{App, Arg, ArgMatches};
  3.  
  4. pub struct UI;
  5. impl UI {
  6. pub fn populate_cli_args(app: clap::App<'static, 'static>) -> clap::App<'static, 'static> {
  7. app.arg(
  8. Arg::with_name("config")
  9. .short("c")
  10. .long("config")
  11. .value_name("FILE")
  12. .help("Sets a custom config file")
  13. .takes_value(true)
  14. )
  15. }
  16. }
  17.  
  18. pub struct FileHandler;
  19. impl FileHandler {
  20. pub fn populate_cli_args(app: clap::App<'static, 'static>) -> clap::App<'static, 'static> {
  21. app.arg(
  22. Arg::with_name("config")
  23. .short("c")
  24. .long("config")
  25. .value_name("FILE")
  26. .help("Sets a custom config file")
  27. .takes_value(true)
  28. )
  29. }
  30. }
  31.  
  32. fn main() {
  33. let mut app = clap::App::new("My super program");
  34.  
  35. app = UI::populate_cli_args(app);
  36. app = FileHandler::populate_cli_args(app);
  37. let matches = app.get_matches();
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement