|
|
@@ -26,9 +26,10 @@ fn main() { |
|
|
|
// Options that are only allowed once. |
|
|
|
Arg::with_name("command") |
|
|
|
.long("command") |
|
|
|
.long_help("The command to execute in each directory.") |
|
|
|
.long_help("The command(s) to execute in each directory.") |
|
|
|
.short("c") |
|
|
|
.required(true) |
|
|
|
.multiple(true) |
|
|
|
.takes_value(true), |
|
|
|
Arg::with_name("depth") |
|
|
|
.default_value(default_depth) |
|
|
@@ -51,9 +52,9 @@ fn main() { |
|
|
|
// Extract boolean flags. |
|
|
|
let verbose = cli.is_present("verbose"); |
|
|
|
|
|
|
|
// Extract the command to execute. |
|
|
|
let target_command = cli |
|
|
|
.value_of("command") |
|
|
|
// Extract the commands to execute. |
|
|
|
let target_commands = cli |
|
|
|
.values_of("command") |
|
|
|
.expect("Failed to extract the command to execute from the CLI"); |
|
|
|
|
|
|
|
// Extract the target directories. |
|
|
@@ -95,35 +96,37 @@ fn main() { |
|
|
|
continue 'walker_loop; |
|
|
|
} |
|
|
|
|
|
|
|
if verbose { |
|
|
|
// Print what we're doing and where we are. |
|
|
|
print!( |
|
|
|
"Executing \"{}\" in {:?} (current depth {})", |
|
|
|
target_command, dir_path, current_depth |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
// Spawn the command at the directory with the specified stdout. |
|
|
|
// Print an error and continue if one occurs. |
|
|
|
let mut child = match command(target_command) |
|
|
|
.stdout(Stdio::inherit()) |
|
|
|
.current_dir(dir_path) |
|
|
|
.spawn() |
|
|
|
{ |
|
|
|
Ok(value) => value, |
|
|
|
Err(err) => { |
|
|
|
println!("Error executing command: {}", err); |
|
|
|
println!(); |
|
|
|
continue 'walker_loop; |
|
|
|
for target_command in target_commands.clone() { |
|
|
|
if verbose { |
|
|
|
// Print what we're doing and where we are. |
|
|
|
print!( |
|
|
|
"Executing \"{}\" in {:?} (current depth {})", |
|
|
|
target_command, dir_path, current_depth |
|
|
|
); |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
// Wait for the command to finish before continuing. |
|
|
|
child.wait().expect("Failed to wait for child process"); |
|
|
|
// Spawn the command at the directory with the specified stdout. |
|
|
|
// Print an error and continue if one occurs. |
|
|
|
let mut child = match command(target_command) |
|
|
|
.stdout(Stdio::inherit()) |
|
|
|
.current_dir(dir_path) |
|
|
|
.spawn() |
|
|
|
{ |
|
|
|
Ok(value) => value, |
|
|
|
Err(err) => { |
|
|
|
println!("Error executing command: {}", err); |
|
|
|
println!(); |
|
|
|
continue 'walker_loop; |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
// If verbose was specified, print an extra newline to make the output more readable. |
|
|
|
if verbose { |
|
|
|
println!(); |
|
|
|
// Wait for the command to finish before continuing. |
|
|
|
child.wait().expect("Failed to wait for child process"); |
|
|
|
|
|
|
|
// If verbose was specified, print an extra newline to make the output more readable. |
|
|
|
if verbose { |
|
|
|
println!(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|