diff options
author | metamuffin <metamuffin@disroot.org> | 2025-10-05 23:42:35 +0200 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2025-10-05 23:42:39 +0200 |
commit | 6d7e8fda46be9d531551670cd66de2161e5dbeb5 (patch) | |
tree | 89ca36fa656a63272b50a56308c4940f41b0405f /server/tools/src/main.rs | |
parent | 1ff014de21c6f37399c222ac16cd5ae9b4bce219 (diff) | |
download | hurrycurry-6d7e8fda46be9d531551670cd66de2161e5dbeb5.tar hurrycurry-6d7e8fda46be9d531551670cd66de2161e5dbeb5.tar.bz2 hurrycurry-6d7e8fda46be9d531551670cd66de2161e5dbeb5.tar.zst |
diagram native svg output
Diffstat (limited to 'server/tools/src/main.rs')
-rw-r--r-- | server/tools/src/main.rs | 49 |
1 files changed, 39 insertions, 10 deletions
diff --git a/server/tools/src/main.rs b/server/tools/src/main.rs index c121d5a1..cb5fda13 100644 --- a/server/tools/src/main.rs +++ b/server/tools/src/main.rs @@ -20,6 +20,7 @@ pub mod book; pub mod book_html; pub mod diagram_dot; pub mod diagram_layout; +pub mod diagram_svg; pub mod graph; pub mod graph_summary; pub mod map_linter; @@ -28,7 +29,9 @@ pub mod recipe_diagram; use crate::{ book::{book, print_book}, book_html::render_html_book, - diagram_dot::diagram_dot, + diagram_dot::{diagram_dot, diagram_dot_svg}, + diagram_layout::diagram_layout, + diagram_svg::diagram_svg, graph::graph, graph_summary::graph_summary, map_linter::check_map, @@ -42,13 +45,27 @@ use hurrycurry_server::data::DataIndex; enum Action { Graph, GraphSummary, - GraphSingle { out: String }, + GraphSingle { + out: String, + #[arg(short)] + custom_svg: bool, + #[arg(short)] + dot_out: bool, + }, Book, BookHtml, - MapDemands { map: String }, - MapItems { map: String }, - MapTiles { map: String }, - CheckMap { map: String }, + MapDemands { + map: String, + }, + MapItems { + map: String, + }, + MapTiles { + map: String, + }, + CheckMap { + map: String, + }, } fn main() -> Result<()> { @@ -57,13 +74,25 @@ fn main() -> Result<()> { match action { Action::Graph => graph()?, Action::GraphSummary => graph_summary()?, - Action::GraphSingle { out } => { + Action::GraphSingle { + out, + custom_svg, + dot_out, + } => { let mut index = DataIndex::default(); index.reload()?; let (data, serverdata, _) = index.generate("5star")?; - let diagram = recipe_diagram(&data, &serverdata, &[&out])?; - let dot = diagram_dot(&data, &diagram)?; - println!("{dot}"); + let mut diagram = recipe_diagram(&data, &serverdata, &[&out])?; + let out = if dot_out { + diagram_dot(&data, &diagram, false)? + } else if custom_svg { + diagram_layout(&mut diagram)?; + diagram_svg(&data, &diagram)? + } else { + diagram_layout(&mut diagram)?; + diagram_dot_svg(&data, &diagram)? + }; + println!("{out}"); } Action::Book => { let mut index = DataIndex::default(); |