6 files changed
+34
-23
No files matched your search
@@ -0,0 +1 @@
|
|||||||
|
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
|
||||||
@@ -3,6 +3,7 @@ use html_parser::Node;
|
|||||||
use std::fmt::Write;
|
use std::fmt::Write;
|
||||||
use std::io::Read;
|
use std::io::Read;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
use std::process::exit;
|
||||||
use structopt::StructOpt;
|
use structopt::StructOpt;
|
||||||
|
|
||||||
pub mod extract_svgs;
|
pub mod extract_svgs;
|
||||||
@@ -40,21 +41,30 @@ impl Translate {
|
|||||||
source,
|
source,
|
||||||
} = self;
|
} = self;
|
||||||
|
|
||||||
let contents = input
|
let contents;
|
||||||
.map(|f| {
|
let temp = input.map(|f| {
|
||||||
std::fs::read_to_string(&f)
|
std::fs::read_to_string(&f).unwrap_or_else(|e| {
|
||||||
.unwrap_or_else(|e| panic!("Could not read input file: {}", e))
|
log::error!("Cloud not read input file: {}.", e);
|
||||||
|
exit(0);
|
||||||
})
|
})
|
||||||
.unwrap_or(source.unwrap_or_else(|| {
|
});
|
||||||
|
if let None = temp {
|
||||||
|
if let Some(s) = source {
|
||||||
|
contents = s;
|
||||||
|
} else {
|
||||||
if atty::is(atty::Stream::Stdin) {
|
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();
|
let mut buffer = String::new();
|
||||||
std::io::stdin().read_to_string(&mut buffer).unwrap();
|
std::io::stdin().read_to_string(&mut buffer).unwrap();
|
||||||
|
|
||||||
buffer.trim().to_string()
|
contents = buffer.trim().to_string();
|
||||||
}));
|
}
|
||||||
|
} else {
|
||||||
|
contents = temp.unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
// parse the input as html and prepare the output
|
// parse the input as html and prepare the output
|
||||||
let dom = Dom::parse(&contents)?;
|
let dom = Dom::parse(&contents)?;
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
|
||||||
+12
-15
@@ -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(())
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
|
||||||
Reference in new issue
Block a user