mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-15 08:30:02 +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" => {
|
||||
if let Some(srcdescriptor) = tokens.next() {
|
||||
if let Some(dstdescriptor) = tokens.next() {
|
||||
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 {
|
||||
(|| {
|
||||
let Some(srcdescriptor) = tokens.next() else {
|
||||
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 {
|
||||
write!(ret, "Usage is copy 'dict:key' 'dict:key' (missing source)").unwrap();
|
||||
}
|
||||
if dstdescriptor.split_once(':').is_none() {
|
||||
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" => {
|
||||
if let Some(descriptor) = tokens.next() {
|
||||
|
|
|
|||
Loading…
Reference in a new issue