Sfoglia il codice sorgente

split into library plus binary

Getty Ritter 10 mesi fa
parent
commit
0faf56ed59
4 ha cambiato i file con 13 aggiunte e 8 eliminazioni
  1. 7 1
      Cargo.toml
  2. 3 0
      src/lib.rs
  3. 3 7
      src/main.rs
  4. 0 0
      tools/from-png/opts.rs

+ 7 - 1
Cargo.toml

@@ -3,7 +3,9 @@ name = "thyme"
 version = "0.1.0"
 edition = "2021"
 
-# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
+[lib]
+name = "thyme"
+path = "src/lib.rs"
 
 [dependencies]
 png = "*"
@@ -13,3 +15,7 @@ pangocairo = "*"
 serde = { version = "*", features = ["derive"] }
 serde_yaml = "*"
 clap = { version = "*", features = ["derive"] }
+
+[[bin]]
+name = "thyme-from-png"
+path = "tools/from-png/main.rs"

+ 3 - 0
src/lib.rs

@@ -0,0 +1,3 @@
+pub mod data;
+pub mod draw;
+pub mod image;

+ 3 - 7
src/main.rs

@@ -1,13 +1,9 @@
-mod data;
-mod draw;
-mod image;
 mod opts;
 
 use clap::Parser;
-
-use crate::data::{Config, Mapping};
-use crate::draw::Pattern;
-use crate::image::Image;
+use thyme::{data::{Config, Mapping},
+            draw::Pattern,
+            image::Image};
 use crate::opts::Options;
 
 fn main() -> Result<(), Box<dyn std::error::Error>> {

src/opts.rs → tools/from-png/opts.rs