mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-17 08:40:52 +00:00
use closure/return to avoid deep indents
This commit is contained in:
parent
fb5811ddc8
commit
0cd2010780
1 changed files with 22 additions and 22 deletions
|
|
@ -158,30 +158,30 @@ impl<'a> ShellCmdApi<'a> for PddbCmd {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
"copy" => {
|
"copy" => {
|
||||||
if let Some(srcdescriptor) = tokens.next() {
|
(|| {
|
||||||
if let Some(dstdescriptor) = tokens.next() {
|
let Some(srcdescriptor) = tokens.next() else {
|
||||||
if let Some((_srcdict, _srckeyname)) = srcdescriptor.split_once(std::path::MAIN_SEPARATOR) {
|
|
||||||
if let Some((_dstdict, _dstkeyname)) = dstdescriptor.split_once(std::path::MAIN_SEPARATOR) {
|
|
||||||
match std::fs::copy(srcdescriptor, dstdescriptor) {
|
|
||||||
Ok(_result) => {
|
|
||||||
write!(ret, "Copy from {} to {} succeeded", srcdescriptor, dstdescriptor).ok();
|
|
||||||
}
|
|
||||||
Err(e) => {
|
|
||||||
write!(ret, "Error copying from {} to {}: {:?}", srcdescriptor, dstdescriptor, e).ok();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
write!(ret, "Destination {} is not of required form 'dict{}key'", dstdescriptor, std::path::MAIN_SEPARATOR).unwrap();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
write!(ret, "Source {} is not of required form 'dict{}key'", srcdescriptor, std::path::MAIN_SEPARATOR).unwrap();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
write!(ret, "Usage is copy 'dict:key' 'dict:key' (missing destination)").unwrap();
|
write!(ret, "Usage is copy 'dict:key' 'dict:key' (missing destination)").unwrap();
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
let Some(dstdescriptor) = tokens.next() else {
|
||||||
|
write!(ret, "Usage is copy 'dict:key' 'dict:key' (missing source)").unwrap();
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
if srcdescriptor.split_once(':').is_none() {
|
||||||
|
write!(ret, "Source {} is not of required form 'dict:key'", srcdescriptor).unwrap();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
if dstdescriptor.split_once(':').is_none() {
|
||||||
write!(ret, "Usage is copy 'dict:key' 'dict:key' (missing source)").unwrap();
|
write!(ret, "Destination {} is not of required form 'dict:key'", dstdescriptor).unwrap();
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
|
if let Err(e) = std::fs::copy(srcdescriptor, dstdescriptor) {
|
||||||
|
write!(ret, "Error copying from {} to {}: {:?}", srcdescriptor, dstdescriptor, e).unwrap();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
write!(ret, "Copy from {} to {} succeeded", srcdescriptor, dstdescriptor).unwrap();
|
||||||
|
})()
|
||||||
}
|
}
|
||||||
"write" => {
|
"write" => {
|
||||||
if let Some(descriptor) = tokens.next() {
|
if let Some(descriptor) = tokens.next() {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue