diff options
| author | A Farzat <a@farzat.xyz> | 2026-02-14 08:37:45 +0300 |
|---|---|---|
| committer | A Farzat <a@farzat.xyz> | 2026-02-14 08:37:45 +0300 |
| commit | 3b8e89a25ad712e14771dcbd35ec021d1da99ad9 (patch) | |
| tree | 1abd777d6dee12f5f134f79e6ceeeba429aced4e /src/main.rs | |
| parent | edf46d8965752725ef3305c9d01decc038457db0 (diff) | |
| download | safaribooks-rs-3b8e89a25ad712e14771dcbd35ec021d1da99ad9.tar.gz safaribooks-rs-3b8e89a25ad712e14771dcbd35ec021d1da99ad9.zip | |
Add functions to create the EPUB skeleton
The base directories and files needed to create the EPUB file output.
Diffstat (limited to 'src/main.rs')
| -rw-r--r-- | src/main.rs | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/main.rs b/src/main.rs index b963850..83743a7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -10,6 +10,7 @@ use clap::Parser; use cli::Args; use cookies::CookieStore; use display::Display; +use epub::EpubSkeleton; use http_client::HttpClient; use orly::{check_login, fetch_book_info}; @@ -68,9 +69,19 @@ async fn main() { }; ui.info(&format!("{:#?}", bookinfo)); - let output_dir = config::books_root().join(format!("(pending) ({})", args.bookid)); + let skeleton = EpubSkeleton::plan(&config::books_root(), &bookinfo.title, &args.bookid); + ui.set_output_dir(skeleton.root.clone()); - ui.set_output_dir(output_dir); + // Create directories and required files + if let Err(e) = (|| -> anyhow::Result<()> { + skeleton.create_dirs()?; + skeleton.write_mimetype()?; + skeleton.write_container_xml()?; + Ok(()) + })() { + ui.error_and_exit(&format!("EPUB skeleton creation failed: {e}")); + } + ui.info("EPUB skeleton ready (mimetype + META-INF/container.xml + OEBPS/)."); ui.info("Initialization complete."); ui.info("No network operations performed in this version."); |
