aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorA Farzat <a@farzat.xyz>2026-02-14 16:30:56 +0300
committerA Farzat <a@farzat.xyz>2026-02-14 16:30:56 +0300
commitca356049faf28ab48b73d04d80d4d11236d3abc6 (patch)
tree53651b39470ab50ec48b9a996947f30432b7cedb /src
parent3b8e89a25ad712e14771dcbd35ec021d1da99ad9 (diff)
downloadsafaribooks-rs-ca356049faf28ab48b73d04d80d4d11236d3abc6.tar.gz
safaribooks-rs-ca356049faf28ab48b73d04d80d4d11236d3abc6.zip
Group skeleton initialization into one function
Diffstat (limited to 'src')
-rw-r--r--src/epub.rs8
-rw-r--r--src/main.rs10
2 files changed, 9 insertions, 9 deletions
diff --git a/src/epub.rs b/src/epub.rs
index 90aeafb..63dfc4b 100644
--- a/src/epub.rs
+++ b/src/epub.rs
@@ -32,6 +32,14 @@ impl EpubSkeleton {
}
}
+ /// Initialize EpubSkeleton by creating directories and required files.
+ pub fn initialize(&self) -> Result<()> {
+ self.create_dirs()?;
+ self.write_mimetype()?;
+ self.write_container_xml()?;
+ Ok(())
+ }
+
/// Create the directories defined in the struct.
pub fn create_dirs(&self) -> Result<()> {
fs::create_dir_all(&self.oebps)
diff --git a/src/main.rs b/src/main.rs
index 83743a7..1fbcfc6 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -73,16 +73,8 @@ async fn main() {
ui.set_output_dir(skeleton.root.clone());
// Create directories and required files
- if let Err(e) = (|| -> anyhow::Result<()> {
- skeleton.create_dirs()?;
- skeleton.write_mimetype()?;
- skeleton.write_container_xml()?;
- Ok(())
- })() {
+ if let Err(e) = skeleton.initialize() {
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.");
}