aboutsummaryrefslogtreecommitdiff
path: root/server/book-export/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'server/book-export/src/main.rs')
-rw-r--r--server/book-export/src/main.rs60
1 files changed, 60 insertions, 0 deletions
diff --git a/server/book-export/src/main.rs b/server/book-export/src/main.rs
new file mode 100644
index 00000000..b57aa04f
--- /dev/null
+++ b/server/book-export/src/main.rs
@@ -0,0 +1,60 @@
+/*
+ Hurry Curry! - a game about cooking
+ Copyright (C) 2025 Hurry Curry! Contributors
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, version 3 of the License only.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>.
+
+*/
+pub mod book_html;
+pub mod diagram_svg;
+
+use crate::book_html::render_html_book;
+use anyhow::Result;
+use clap::{Parser, ValueEnum};
+use hurrycurry_data::{book::book, index::DataIndex};
+use hurrycurry_locale::FALLBACK_LOCALE;
+
+#[derive(Parser)]
+struct Args {
+ #[arg(short, long)]
+ format: ExportFormat,
+ #[arg(short, long, default_value = "5star")]
+ map: String,
+}
+
+#[derive(ValueEnum, Clone, Copy)]
+enum ExportFormat {
+ Json,
+ Html,
+}
+
+fn main() -> Result<()> {
+ env_logger::init_from_env("LOG");
+ let args = Args::parse();
+
+ let mut index = DataIndex::default();
+ index.reload()?;
+ let (data, serverdata) = index.generate(&args.map)?;
+
+ let book = book(&data, &serverdata)?;
+
+ match args.format {
+ ExportFormat::Json => {
+ println!("{}", serde_json::to_string(&book).unwrap())
+ }
+ ExportFormat::Html => {
+ println!("{}", render_html_book(&data, &book, &FALLBACK_LOCALE));
+ }
+ }
+ Ok(())
+}