Small tweaks

This commit is contained in:
lights0123 2021-10-27 16:59:08 -04:00 committed by Ben Schattinger
parent 3311e0d358
commit a8dddd1756

View file

@ -163,13 +163,12 @@ pub fn run() -> bool {
match res {
Ok(_) => {
println!("Upload {}: Ok", dest);
bar.finish_with_message(&format!("Upload {}: Ok", dest));
}
Err(error) => {
bar.abandon_with_message(&format!("Failed: {}", error));
}
}
bar.finish();
}
} else {
eprintln!("Couldn't find any device");
@ -247,8 +246,7 @@ pub fn run() -> bool {
.to_string();
let mut buf = vec![];
let mut f = File::open(cwd().join(&file))
.unwrap_or_else(|err| {
let mut f = File::open(cwd().join(&file)).unwrap_or_else(|err| {
eprintln!("Failed to open file: {}", err);
std::process::exit(1);
});
@ -298,7 +296,10 @@ pub fn run() -> bool {
eprintln!("Couldn't find any device");
}
}
SubCommand::Copy(Copy { from_path, dist_path }) => {
SubCommand::Copy(Copy {
from_path,
dist_path,
}) => {
if let Some(handle) = get_dev() {
match handle.copy_file(&from_path, &dist_path) {
Ok(_) => {
@ -312,7 +313,10 @@ pub fn run() -> bool {
eprintln!("Couldn't find any device");
}
}
SubCommand::Move(Move { from_path, dist_path }) => {
SubCommand::Move(Move {
from_path,
dist_path,
}) => {
if let Some(handle) = get_dev() {
match handle.move_file(&from_path, &dist_path) {
Ok(_) => {
@ -358,13 +362,16 @@ pub fn run() -> bool {
if let Some(handle) = get_dev() {
match handle.list_dir(&path) {
Ok(dir_list) => {
for i in 0..dir_list.len() {
let item = dir_list.get(i).unwrap();
let mut item_name = String::from(item.name().to_str().unwrap());
for item in dir_list.iter() {
println!(
"{}{}",
item.name().to_str().unwrap(),
if item.entry_type() == EntryType::Directory {
item_name += "/";
"/"
} else {
""
}
println!("{}", item_name);
);
}
}
Err(error) => {