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.

31 lines
1.0 KiB

4 years ago
4 years ago
4 years ago
  1. use clap::{Arg, Error, ErrorKind};
  2. use clap_nested::{Command};
  3. use crate::lib::m3u::{Playlist};
  4. pub fn get_command<'a>() -> Command<'a, str>{
  5. Command::new("dedupe")
  6. .description("dedupe a m3u playlist")
  7. .options(|app| {
  8. app.arg(Arg::with_name("playlist")
  9. .help("Path of the playlist(s) to de-duplicate")
  10. .index(1)
  11. .multiple(true)
  12. .required(true)
  13. )
  14. })
  15. .runner(| _args, matches| {
  16. // println!("Running dedupe, logging = {}", args);
  17. match matches.values_of("playlist") {
  18. Some(playlists) => {
  19. for path in playlists {
  20. let playlist = Playlist::read(path)?;
  21. println!("{:?}", playlist);
  22. }
  23. Ok(())
  24. },
  25. None => Err(
  26. Error::with_description("playlist must be provided", ErrorKind::EmptyValue))
  27. }
  28. })
  29. }