mirror of https://github.com/Y2Z/monolith
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
1.2 KiB
Rust
40 lines
1.2 KiB
Rust
#[macro_use]
|
|
extern crate clap;
|
|
extern crate monolith;
|
|
|
|
use clap::{App, Arg};
|
|
use monolith::html::{html_to_dom, print_dom, walk_and_embed_assets};
|
|
use monolith::http::{is_valid_url, retrieve_asset};
|
|
|
|
fn main() {
|
|
let command = App::new("monolith")
|
|
.version(crate_version!())
|
|
.author(crate_authors!("\n"))
|
|
.about(crate_description!())
|
|
.arg(
|
|
Arg::with_name("url")
|
|
.required(true)
|
|
.takes_value(true)
|
|
.index(1)
|
|
.help("URL to download"),
|
|
)
|
|
.args_from_usage("-j, --no-js 'Excludes JavaScript'")
|
|
.args_from_usage("-i, --no-images 'Removes images'")
|
|
.get_matches();
|
|
|
|
// Process the command
|
|
let arg_target = command.value_of("url").unwrap();
|
|
let opt_no_js = command.is_present("no-js");
|
|
let opt_no_img = command.is_present("no-images");
|
|
|
|
if is_valid_url(arg_target) {
|
|
let data = retrieve_asset(&arg_target, false, "");
|
|
let dom = html_to_dom(&data.unwrap());
|
|
|
|
walk_and_embed_assets(&arg_target, &dom.document, opt_no_js, opt_no_img);
|
|
|
|
print_dom(&dom.document);
|
|
println!(); // Ensure newline at end of output
|
|
}
|
|
}
|