You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 lines
1.3 KiB

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
  1. use clap::{Arg};
  2. use clap_nested::{Commander};
  3. mod command;
  4. mod lib;
  5. const VERSION: Option<&'static str> = option_env!("CARGO_PKG_VERSION");
  6. fn main() {
  7. match Commander::new()
  8. .options(|app| {
  9. app.name("Walkman Tools")
  10. .version(VERSION.unwrap_or("UNKNOWN"))
  11. .author("Drew Short <warrick@sothr.com>")
  12. .about("Management tool for walkman mp3 players")
  13. .arg(
  14. Arg::with_name("verbose")
  15. .short("v")
  16. .long("verbose")
  17. .global(true)
  18. .takes_value(true)
  19. .value_name("VERBOSITY")
  20. .help("Sets the logging verbosity, defaults to \"INFO\""),
  21. )
  22. .arg(
  23. Arg::with_name("dry-run")
  24. .long("dry-run")
  25. .global(true)
  26. .takes_value(false)
  27. .help("Make no changes and print expected output")
  28. )
  29. })
  30. .args(|_args, matches| matches.value_of("verbose").unwrap_or("INFO"))
  31. .add_cmd(command::dedupe::get_command())
  32. .no_cmd(|_args, _matches| {
  33. println!("No subcommand matched");
  34. Ok(())
  35. })
  36. .run() {
  37. Ok(_) => std::process::exit(0),
  38. Err(err) => println!("{}", err)
  39. }
  40. }