fix: fmt code

This commit is contained in:
mrxiaozhuox committed 2022-01-19 00:42:43 +08:00
1 parent ccdd62b032
commit 7f53b7de6a
6 files changed
+36 -33

No files matched your search

+1
View File
@@ -0,0 +1 @@
+1
View File
@@ -0,0 +1 @@
+20 -18
View File
@@ -34,7 +34,6 @@ pub struct Translate {
impl Translate { impl Translate {
pub fn translate(self) -> anyhow::Result<()> { pub fn translate(self) -> anyhow::Result<()> {
let Translate { let Translate {
component: as_component, component: as_component,
input, input,
@@ -43,25 +42,28 @@ impl Translate {
} = self; } = self;
let contents; let contents;
let temp = input let temp = input.map(|f| {
.map(|f| { std::fs::read_to_string(&f).unwrap_or_else(|e| {
std::fs::read_to_string(&f).unwrap_or_else(|e| { // panic!("Could not read input file: {}", e)
// panic!("Could not read input file: {}", e) log::error!("Cloud not read input file: {}.", e);
log::error!("Cloud not read input file: {}.", e);
exit(0);
})
});
if let None = temp {
if atty::is(atty::Stream::Stdin) {
// panic!("No input file, source, or stdin to translate from");
log::error!("No input file, source, or stdin to translate from.");
exit(0); exit(0);
})
});
if let None = temp {
if let Some(s) = source {
contents = s;
} else {
if atty::is(atty::Stream::Stdin) {
// panic!("No input file, source, or stdin to translate from");
log::error!("No input file, source, or stdin to translate from.");
exit(0);
}
let mut buffer = String::new();
std::io::stdin().read_to_string(&mut buffer).unwrap();
contents = buffer.trim().to_string();
} }
let mut buffer = String::new();
std::io::stdin().read_to_string(&mut buffer).unwrap();
contents = buffer.trim().to_string();
} else { } else {
contents = temp.unwrap(); contents = temp.unwrap();
} }
+1
View File
@@ -0,0 +1 @@
+12 -15
View File
@@ -9,24 +9,21 @@ async fn main() -> Result<()> {
match args.action { match args.action {
Commands::Translate(opts) => { Commands::Translate(opts) => {
opts.translate(); opts.translate();
} } // Commands::Build(_) => {
// //
// }
// Commands::Build(_) => { // Commands::Clean(_) => {
// // // //
// } // }
// Commands::Config(_) => {
// //
// }
// Commands::Clean(_) => { // Commands::Serve(_) => {
// // // //
// } // }
// Commands::Config(_) => {
// //
// }
// Commands::Serve(_) => {
// //
// }
} }
Ok(()) Ok(())
+1
View File
@@ -0,0 +1 @@