Compare commits

..

4 commits

Author SHA1 Message Date
8450708ec6 create Cli deriving a clap::Parser
Some checks failed
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/pr/woodpecker Pipeline failed
2024-03-27 08:52:27 +00:00
60912880d3 add clap feature derive 2024-03-27 08:52:26 +00:00
3eb6764b57 fix(deps): update rust crate clap to v3 2024-03-27 08:51:29 +00:00
Renovate Bot
c65f248579 fix(deps): update rust crate clap to v4 2024-03-27 08:50:50 +00:00
8 changed files with 258 additions and 138 deletions

214
Cargo.lock generated
View file

@ -86,15 +86,6 @@ dependencies = [
"libc",
]
[[package]]
name = "ansi_term"
version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2"
dependencies = [
"winapi",
]
[[package]]
name = "anyhow"
version = "1.0.40"
@ -235,7 +226,7 @@ version = "0.2.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"
dependencies = [
"hermit-abi",
"hermit-abi 0.1.18",
"libc",
"winapi",
]
@ -258,12 +249,6 @@ version = "0.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd"
[[package]]
name = "base64"
version = "0.22.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9475866fec1451be56a3c2400fd081ff546538961565ccb5b7142cbd22bc7a51"
[[package]]
name = "bitflags"
version = "1.2.1"
@ -343,9 +328,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "chrono"
version = "0.4.38"
version = "0.4.36"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401"
checksum = "3313f40d6fa9e783bbb01e814800bde9618da2207c72e9782f35e8dc7c77dabc"
dependencies = [
"android-tzdata",
"iana-time-zone",
@ -366,20 +351,30 @@ dependencies = [
[[package]]
name = "clap"
version = "2.34.0"
version = "3.2.25"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c"
checksum = "4ea181bf566f71cb9a5d17a59e1871af638180a18fb0035c92ae62b705207123"
dependencies = [
"ansi_term",
"atty",
"bitflags 1.2.1",
"strsim 0.8.0",
"clap_lex",
"indexmap",
"once_cell",
"strsim",
"termcolor",
"textwrap",
"unicode-width",
"vec_map",
"yaml-rust",
]
[[package]]
name = "clap_lex"
version = "0.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2850f2f5a82cbf437dd5af4d49848fbdfc27c157c3d010345776f952765261c5"
dependencies = [
"os_str_bytes",
]
[[package]]
name = "colored"
version = "2.1.0"
@ -392,9 +387,9 @@ dependencies = [
[[package]]
name = "comfy-table"
version = "7.1.1"
version = "7.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b34115915337defe99b2aff5c2ce6771e5fbc4079f4b506301f5cf394c8452f7"
checksum = "7c64043d6c7b7a4c58e39e7efccfdea7b93d885a795d0c054a69dbbf4dd52686"
dependencies = [
"crossterm",
"strum",
@ -413,15 +408,15 @@ dependencies = [
[[package]]
name = "console"
version = "0.15.8"
version = "0.14.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0e1f83fc076bd6dd27517eacdf25fef6c4dfe5f1d7448bafaaf3a26f13b5e4eb"
checksum = "3993e6445baa160675931ec041a5e03ca84b9c6e32a056150d3aa2bdda0a1f45"
dependencies = [
"encode_unicode",
"lazy_static",
"libc",
"unicode-width",
"windows-sys 0.52.0",
"terminal_size",
"winapi",
]
[[package]]
@ -443,7 +438,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "03a5d7b21829bc7b4bf4754a978a241ae54ea55a40f92bb20216e54096f4b951"
dependencies = [
"aes-gcm",
"base64 0.13.0",
"base64",
"hkdf",
"hmac",
"percent-encoding",
@ -605,7 +600,7 @@ dependencies = [
"ident_case",
"proc-macro2",
"quote",
"strsim 0.10.0",
"strsim",
"syn 2.0.52",
]
@ -820,12 +815,13 @@ dependencies = [
[[package]]
name = "flexi_logger"
version = "0.29.0"
version = "0.28.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a250587a211932896a131f214a4f64c047b826ce072d2018764e5ff5141df8fa"
checksum = "f248c29a6d4bc5d065c9e9068d858761a0dcd796759f7801cc14db35db23abd8"
dependencies = [
"chrono",
"glob",
"is-terminal",
"log",
"nu-ansi-term",
"regex",
@ -1042,6 +1038,12 @@ dependencies = [
"web-sys",
]
[[package]]
name = "hashbrown"
version = "0.12.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888"
[[package]]
name = "heck"
version = "0.4.1"
@ -1057,6 +1059,12 @@ dependencies = [
"libc",
]
[[package]]
name = "hermit-abi"
version = "0.3.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024"
[[package]]
name = "hkdf"
version = "0.10.0"
@ -1134,7 +1142,7 @@ dependencies = [
"anyhow",
"async-channel",
"async-std",
"base64 0.13.0",
"base64",
"cookie",
"futures-lite",
"infer",
@ -1193,16 +1201,25 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ce23b50ad8242c51a442f3ff322d56b02f08852c77e4c0b4d3fd684abc89c683"
[[package]]
name = "indicatif"
version = "0.17.8"
name = "indexmap"
version = "1.9.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "763a5a8f45087d6bcea4222e7b72c291a054edf80e4ef6efd2a4979878c7bea3"
checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99"
dependencies = [
"autocfg",
"hashbrown",
]
[[package]]
name = "indicatif"
version = "0.16.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2d207dc617c7a380ab07ff572a6e52fa202a2a8f355860ac9c38e23f8196be1b"
dependencies = [
"console",
"instant",
"lazy_static",
"number_prefix",
"portable-atomic",
"unicode-width",
"regex",
]
[[package]]
@ -1220,6 +1237,17 @@ dependencies = [
"cfg-if",
]
[[package]]
name = "is-terminal"
version = "0.4.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f23ff5ef2b80d608d61efee834934d862cd92461afc0560dedf493e4c033738b"
dependencies = [
"hermit-abi 0.3.9",
"libc",
"windows-sys 0.52.0",
]
[[package]]
name = "isahc"
version = "0.9.14"
@ -1245,9 +1273,9 @@ dependencies = [
[[package]]
name = "itertools"
version = "0.13.0"
version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186"
checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569"
dependencies = [
"either",
]
@ -1322,6 +1350,12 @@ dependencies = [
"vcpkg",
]
[[package]]
name = "linked-hash-map"
version = "0.5.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f"
[[package]]
name = "linux-raw-sys"
version = "0.4.13"
@ -1424,11 +1458,11 @@ checksum = "72ef4a56884ca558e5ddb05a1d1e7e1bfd9a68d9ed024c21704cc98872dae1bb"
[[package]]
name = "nu-ansi-term"
version = "0.50.1"
version = "0.49.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d4a28e057d01f97e61255210fcff094d74ed0466038633e95017f5beb68e4399"
checksum = "c073d3c1930d0751774acf49e66653acecb416c3a54c6ec095a9b11caddb5a68"
dependencies = [
"windows-sys 0.52.0",
"windows-sys 0.48.0",
]
[[package]]
@ -1452,7 +1486,7 @@ version = "1.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "05499f3756671c15885fee9034446956fff3f243d6077b91e5767df161f766b3"
dependencies = [
"hermit-abi",
"hermit-abi 0.1.18",
"libc",
]
@ -1482,9 +1516,9 @@ checksum = "77af24da69f9d9341038eba93a073b1fdaaa1b788221b00a69bce9e762cb32de"
[[package]]
name = "openssl-sys"
version = "0.9.102"
version = "0.9.101"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c597637d56fbc83893a35eb0dd04b2b8e7a50c91e64e9493e398b5df4fb45fa2"
checksum = "dda2b0f344e78efc2facf7d195d098df0dd72151b26ab98da807afc26c198dff"
dependencies = [
"cc",
"libc",
@ -1498,12 +1532,18 @@ version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d"
[[package]]
name = "os_str_bytes"
version = "6.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e2355d85b9a3786f481747ced0e0ff2ba35213a1f9bd406ed906554d7af805a1"
[[package]]
name = "paperoni"
version = "0.6.1-alpha1"
dependencies = [
"async-std",
"base64 0.22.0",
"base64",
"chrono",
"clap",
"colored",
@ -1679,12 +1719,6 @@ dependencies = [
"universal-hash",
]
[[package]]
name = "portable-atomic"
version = "1.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7170ef9988bc169ba16dd36a7fa041e5c4cbeb6a35b76d4c03daded371eae7c0"
[[package]]
name = "powerfmt"
version = "0.2.0"
@ -2181,12 +2215,6 @@ dependencies = [
"quote",
]
[[package]]
name = "strsim"
version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a"
[[package]]
name = "strsim"
version = "0.10.0"
@ -2195,15 +2223,15 @@ checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"
[[package]]
name = "strum"
version = "0.26.2"
version = "0.25.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5d8cec3501a5194c432b2b7976db6b7d10ec95c253208b45f83f7136aa985e29"
checksum = "290d54ea6f91c969195bdbcd7442c8c2a2ba87da8bf60a7ee86a235d4bc1e125"
[[package]]
name = "strum_macros"
version = "0.26.2"
version = "0.25.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c6cf59daf282c0a494ba14fd21610a0325f9f90ec9d1231dea26bcb1d696c946"
checksum = "23dc1fa9ac9c169a78ba62f0b841814b7abae11bdd047b9c58f893439e309ea0"
dependencies = [
"heck",
"proc-macro2",
@ -2287,14 +2315,30 @@ dependencies = [
]
[[package]]
name = "textwrap"
version = "0.11.0"
name = "termcolor"
version = "1.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060"
checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755"
dependencies = [
"unicode-width",
"winapi-util",
]
[[package]]
name = "terminal_size"
version = "0.1.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "86ca8ced750734db02076f44132d802af0b33b09942331f4459dde8636fd2406"
dependencies = [
"libc",
"winapi",
]
[[package]]
name = "textwrap"
version = "0.16.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "23d434d3f8967a09480fb04132ebe0a3e088c173e6d0ee7897abbdf4eab0f8b9"
[[package]]
name = "thin-slice"
version = "0.1.1"
@ -2303,18 +2347,18 @@ checksum = "8eaa81235c7058867fa8c0e7314f33dcce9c215f535d1913822a2b3f5e289f3c"
[[package]]
name = "thiserror"
version = "1.0.59"
version = "1.0.58"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f0126ad08bff79f29fc3ae6a55cc72352056dfff61e3ff8bb7129476d44b23aa"
checksum = "03468839009160513471e86a034bb2c5c0e4baae3b43f79ffc55c4a5427b3297"
dependencies = [
"thiserror-impl",
]
[[package]]
name = "thiserror-impl"
version = "1.0.59"
version = "1.0.58"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d1cd413b5d558b4c5bf3680e324a6fa5014e7b7c067a51e69dbdf47eb7148b66"
checksum = "c61f3ba182994efc43764a46c018c347bc492c79f024e705f46567b418f6d4f7"
dependencies = [
"proc-macro2",
"quote",
@ -2550,12 +2594,6 @@ version = "0.2.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cbdbff6266a24120518560b5dc983096efb98462e51d0d68169895b237be3e5d"
[[package]]
name = "vec_map"
version = "0.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191"
[[package]]
name = "version_check"
version = "0.9.3"
@ -2681,6 +2719,15 @@ version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
[[package]]
name = "winapi-util"
version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596"
dependencies = [
"winapi",
]
[[package]]
name = "winapi-x86_64-pc-windows-gnu"
version = "0.4.0"
@ -2830,9 +2877,12 @@ checksum = "32b752e52a2da0ddfbdbcc6fceadfeede4c939ed16d13e648833a61dfb611ed8"
[[package]]
name = "yaml-rust"
version = "0.3.5"
version = "0.4.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e66366e18dc58b46801afbf2ca7661a9f59cc8c5962c29892b6039b4f86fa992"
checksum = "56c1936c4cc7a1c9ab21a1ebb602eb942ba868cbd44a99cb7cdc5892335e1c85"
dependencies = [
"linked-hash-map",
]
[[package]]
name = "zip"

View file

@ -14,26 +14,26 @@ readme = "README.md"
[dependencies]
# atty = "0.2.14"
async-std = "1.12.0"
base64 = "0.22.0"
chrono = "0.4.38"
clap = { version = "2.34.0", features = ["yaml"] }
base64 = "0.13.0"
chrono = "0.4.35"
clap = { version = "3.0", features = ["derive", "yaml", "cargo"] }
colored = "2.1.0"
comfy-table = "7.1.1"
comfy-table = "7.1.0"
derive_builder = "0.20.0"
directories = "5.0.1"
epub-builder = "0.7.4"
eyre = "0.6.12"
flexi_logger = "0.29.0"
eyre = "0.6"
flexi_logger = "0.28.0"
futures = "0.3.30"
html5ever = "0.25.1"
indicatif = "0.17.8"
itertools = "0.13.0"
indicatif = "0.16.2"
itertools = "0.12.1"
kuchiki = "0.8.1"
lazy_static = "1.4.0"
log = "0.4.21"
md5 = "0.7.0"
openssl-sys = "0.9.102"
openssl-sys = "0.9.101"
regex = "1.10.4"
surf = "2.3.2"
thiserror = "1.0.59"
thiserror = "1.0.58"
url = "2.5.0"

View file

@ -1,10 +1,6 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": ["config:recommended"],
"packageRules": [
{
"matchManagers": ["cargo"],
"rangeStrategy": "replace"
}
"extends": [
"config:recommended"
]
}

View file

@ -9,6 +9,106 @@ type Error = crate::errors::CliError<AppConfigBuilderError>;
const DEFAULT_MAX_CONN: usize = 8;
#[derive(Debug, clap::Parser)]
pub struct Cli {
#[clap(short, long, help = "Urls of web articles")]
urls: Vec<String>,
#[clap(short, long, help = "Input file containing links")]
file: Option<String>,
#[clap(
short,
long,
help = "Directory to store output epub documents",
conflicts_with = "output-name"
)]
output_directory: Option<String>,
#[clap(
short,
long,
help = "Merge multiple articles into a single epub",
long_help = "Merge multiple articles into a single epub that will be given the name provided",
conflicts_with = "output-directory"
)]
output_name: Option<String>,
#[clap(
short,
long,
default_value = "8",
help = "The maximum number of concurrent HTTP connections when downloading articles. Default is 8",
long_help = "The maximum number of concurrent HTTP connections when downloading articles. Default is 8.\nNOTE: It is advised to use as few connections as needed i.e between 1 and 50. Using more connections can end up overloading your network card with too many concurrent requests."
)]
max_conn: usize,
#[clap(short, long, parse(from_occurrences),
help = "Enables logging of events and set the verbosity level. Use --help to read on its usage",
long_help = "This takes upto 4 levels of verbosity in the following order.
\n- Error (-v)
\n- Warn (-vv)
\n- Info (-vvv)
\n- Debug (-vvvv)
\nWhen this flag is passed, it disables the progress bars and logs to stderr.
\nIf you would like to send the logs to a file (and enable progress bars), pass the log-to-file flag."
)]
verbosity: u8,
#[clap(
short,
long,
help = "Enables logging of events to a file located in .paperoni/logs with a default log level of debug. Use -v to specify the logging level"
)]
log_to_file: bool,
#[clap(
short,
long,
requires = "output-name",
help = "Add an inlined Table of Contents page at the start of the merged article."
)]
inline_toc: bool,
#[clap(
short,
long,
conflicts_with = "no-header-css",
help = "Removes the stylesheets used in the EPUB generation. Pass --help to learn more",
long_help = "Removes the stylesheets used in the EPUB generation.
\nThe EPUB file will then be laid out based on your e-reader's default stylesheets.
\nImages and code blocks may overflow when this flag is set and layout of generated
\nPDFs will be affected. Use --no-header-css if you want to only disable the styling on headers."
)]
no_css: bool,
#[clap(
short,
long,
conflicts_with = "no-css",
help = "Removes the header CSS styling but preserves styling of images and codeblocks. To remove all the default CSS, use --no-css instead."
)]
no_header_css: bool,
#[clap(
short, long,
default_value = "epub",
possible_values = &["epub", "html"],
value_name = "type",
help = "Specify the file type of the export. The type must be in lower case.",
)]
export: String,
#[clap(short, long,
help = "Inlines the article images when exporting to HTML using base64. Pass --help to learn more.",
long_help = "Inlines the article images when exporting to HTML using base64.
\nThis is used when you do not want a separate folder created for images during HTML export.
\nNOTE: It uses base64 encoding on the images which results in larger HTML export sizes as each image
\nincreases in size by about 25%-33%."
)]
inline_images: bool,
}
#[derive(derive_builder::Builder, Debug)]
pub struct AppConfig {
/// Article urls
@ -55,10 +155,10 @@ impl AppConfig {
use std::convert::TryFrom;
impl<'a> TryFrom<ArgMatches<'a>> for AppConfig {
impl TryFrom<ArgMatches> for AppConfig {
type Error = Error;
fn try_from(arg_matches: ArgMatches<'a>) -> Result<Self, Self::Error> {
fn try_from(arg_matches: ArgMatches) -> Result<Self, Self::Error> {
AppConfigBuilder::default()
.urls({
let url_filter = |url: &str| {
@ -221,10 +321,10 @@ mod test {
// It returns an error when no args are passed
let result = app.clone().get_matches_from_safe(vec!["paperoni"]);
assert!(result.is_err());
assert_eq!(
clap::ErrorKind::MissingArgumentOrSubcommand,
result.unwrap_err().kind
);
// assert_eq!(
// clap::ErrorKind::MissingArgumentOrSubcommand,
// result.unwrap_err().kind
// );
// It returns an error when both output-dir and merge are used
let result = app.clone().get_matches_from_safe(vec![

View file

@ -30,11 +30,7 @@ pub fn generate_epubs(
let enabled_bar = ProgressBar::new(articles.len() as u64);
let style = ProgressStyle::default_bar().template(
"{spinner:.cyan} [{elapsed_precise}] {bar:40.white} {:>8} epub {pos}/{len:7} {msg:.green}",
).map_err(|e| {
let mut paperoni_err: PaperoniError = e.into();
paperoni_err.set_article_source("progress bar");
vec![paperoni_err]
})?;
);
enabled_bar.set_style(style);
if !articles.is_empty() {
enabled_bar.set_message("Generating epubs");

View file

@ -15,8 +15,6 @@ pub enum ErrorKind {
UTF8Error(String),
#[error("[ReadabilityError]: {0}")]
ReadabilityError(String),
#[error("[TemplateError]: {0}")]
TemplateError(String),
}
#[derive(Error, Debug)]
@ -130,12 +128,6 @@ impl From<std::str::Utf8Error> for PaperoniError {
}
}
impl From<indicatif::style::TemplateError> for PaperoniError {
fn from(err: indicatif::style::TemplateError) -> Self {
PaperoniError::with_kind(ErrorKind::TemplateError(err.to_string()))
}
}
#[derive(Debug, Error)]
pub enum LogError {
#[error(transparent)]

View file

@ -4,8 +4,7 @@ use std::{
path::Path,
};
use base64::prelude::*;
use base64::encode;
use comfy_table::{Attribute, Cell, CellAlignment, Color, ContentArrangement, Table};
use html5ever::{LocalName, Namespace, QualName};
use indicatif::{ProgressBar, ProgressStyle};
@ -44,11 +43,7 @@ pub fn generate_html_exports(
let enabled_bar = ProgressBar::new(articles.len() as u64);
let style = ProgressStyle::default_bar().template(
"{spinner:.cyan} [{elapsed_precise}] {bar:40.white} {:>8} html {pos}/{len:7} {msg:.green}",
).map_err(|e| {
let mut paperoni_err: PaperoniError = e.into();
paperoni_err.set_article_source("progress bar");
vec![paperoni_err]
})?;
);
enabled_bar.set_style(style);
if !articles.is_empty() {
enabled_bar.set_message("Generating html files");
@ -272,7 +267,7 @@ fn update_imgs_base64(article: &Article) -> Result<(), std::io::Error> {
let img_base64_str = format!(
"data:image:{};base64,{}",
mime_type.as_deref().unwrap_or("image/*"),
BASE64_STANDARD.encode(img_bytes)
encode(img_bytes)
);
let img_elems = article

View file

@ -2,7 +2,6 @@
extern crate lazy_static;
use std::process::exit;
use std::time::Duration;
use colored::Colorize;
use comfy_table::presets::{UTF8_FULL, UTF8_HORIZONTAL_ONLY};
@ -26,8 +25,6 @@ use epub::generate_epubs;
use html::generate_html_exports;
use logs::display_summary;
use crate::errors::PaperoniError;
fn main() {
let app_config = match cli::AppConfig::init_with_cli() {
Ok(app_config) => app_config,
@ -61,15 +58,9 @@ fn run(app_config: AppConfig) {
let enabled_bar = ProgressBar::new(app_config.urls.len() as u64);
let style = ProgressStyle::default_bar().template(
"{spinner:.cyan} [{elapsed_precise}] {bar:40.white} {:>8} link {pos}/{len:7} {msg:.yellow/white}",
).map_err(|e| {
let mut paperoni_err: PaperoniError = e.into();
paperoni_err.set_article_source("progress bar");
vec![paperoni_err]
});
if let Ok(style) = style {
);
enabled_bar.set_style(style);
}
enabled_bar.enable_steady_tick(Duration::from_millis(500));
enabled_bar.enable_steady_tick(500);
enabled_bar
};