Added --no-context flag to disable adding context comment

pull/100/head
Emi Simpson 4 years ago
parent 27c9fb4cd3
commit 9be3982dc6
No known key found for this signature in database
GPG Key ID: 68FAB2E2E6DFC98B

@ -12,6 +12,7 @@ pub struct AppArgs {
pub output: String,
pub silent: bool,
pub user_agent: String,
pub no_context: bool,
}
const DEFAULT_USER_AGENT: &str =
@ -31,6 +32,7 @@ impl AppArgs {
.help("URL to download"),
)
// .args_from_usage("-a, --include-audio 'Embed audio sources'")
.args_from_usage("-C, --no-context 'Exclude time and original URL in output'")
.args_from_usage("-c, --no-css 'Ignore styles'")
.args_from_usage("-f, --no-frames 'Exclude iframes'")
.args_from_usage("-i, --no-images 'Remove images'")
@ -48,6 +50,7 @@ impl AppArgs {
.value_of("url")
.expect("please set target url")
.to_string();
app_args.no_context = app.is_present("no-context");
app_args.no_css = app.is_present("no-css");
app_args.no_frames = app.is_present("no-frames");
app_args.no_images = app.is_present("no-images");

@ -95,16 +95,18 @@ fn main() {
app_args.isolate,
);
html.insert_str(
0,
&format!(
"<!--- Downloaded from {} on {}using {} v{} -->\n",
&final_url,
downloaded_time.to_local().rfc822(),
env!("CARGO_PKG_NAME"),
env!("CARGO_PKG_VERSION"),
),
);
if !app_args.no_context {
html.insert_str(
0,
&format!(
"<!--- Downloaded from {} on {}using {} v{} -->\n",
&final_url,
downloaded_time.rfc822(),
env!("CARGO_PKG_NAME"),
env!("CARGO_PKG_VERSION"),
),
);
}
if app_args.output == str!() {
println!("{}", html);

Loading…
Cancel
Save