Browse Source

Added dry-run global argument

master
Drew Short 5 years ago
parent
commit
9b984345ab
  1. 9
      src/command/dedupe.rs
  2. 7
      src/main.rs

9
src/command/dedupe.rs

@ -15,13 +15,16 @@ pub fn get_command<'a>() -> Command<'a, str>{
) )
}) })
.runner(| _args, matches| { .runner(| _args, matches| {
// println!("Running dedupe, logging = {}", args);
let dry_run = matches.is_present("dry-run");
match matches.values_of("playlist") { match matches.values_of("playlist") {
Some(playlists) => { Some(playlists) => {
for path in playlists { for path in playlists {
let playlist = Playlist::read(path)?; let playlist = Playlist::read(path)?;
println!("{:?}", playlist);
playlist.write(path)?
if ! dry_run {
playlist.write(path)?
} else {
println!("{:?}", playlist);
}
} }
Ok(()) Ok(())
}, },

7
src/main.rs

@ -22,6 +22,13 @@ fn main() {
.value_name("VERBOSITY") .value_name("VERBOSITY")
.help("Sets the logging verbosity, defaults to \"INFO\""), .help("Sets the logging verbosity, defaults to \"INFO\""),
) )
.arg(
Arg::with_name("dry-run")
.long("dry-run")
.global(true)
.takes_value(false)
.help("Make no changes and print expected output")
)
}) })
.args(|_args, matches| matches.value_of("verbose").unwrap_or("INFO")) .args(|_args, matches| matches.value_of("verbose").unwrap_or("INFO"))
.add_cmd(command::dedupe::get_command()) .add_cmd(command::dedupe::get_command())

Loading…
Cancel
Save