aboutsummaryrefslogtreecommitdiff
path: root/build.rs
diff options
context:
space:
mode:
authorNicholas Johnson <nick@nicholasjohnson.ch>2024-04-22 00:00:00 +0000
committerNicholas Johnson <nick@nicholasjohnson.ch>2024-04-22 00:00:00 +0000
commite49033ae32b31e3056017c51180d6b1a4412e98f70170bca8db74b1f2a8ad6e5 (patch)
tree25db6a9623419810aa94ca378c2a68c91a3372d9d9f502922a0f3ab44f52ffde /build.rs
parentc10eedb6af1c8e77fcd4d584d3783f92dfaf85f2f9ec3a1317eb44ae40ec6293 (diff)
downloadhitomezashi-rs-e49033ae32b31e3056017c51180d6b1a4412e98f70170bca8db74b1f2a8ad6e5.tar.gz
hitomezashi-rs-e49033ae32b31e3056017c51180d6b1a4412e98f70170bca8db74b1f2a8ad6e5.zip
Implement build script for generating the manual
Diffstat (limited to 'build.rs')
-rw-r--r--build.rs45
1 files changed, 45 insertions, 0 deletions
diff --git a/build.rs b/build.rs
new file mode 100644
index 0000000..990d2b5
--- /dev/null
+++ b/build.rs
@@ -0,0 +1,45 @@
+/*
+ hitomezashi-rs Generates classical colored Hitomezashi stitch patterns
+ Copyright (C) 2024 Nicholas Johnson
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>.
+*/
+
+use clap::CommandFactory;
+use std::env;
+use std::path::PathBuf;
+
+include!("src/cli.rs");
+
+fn main() -> std::io::Result<()> {
+ let out_dir = match env::var_os("OUT_DIR") {
+ None => return Ok(()),
+ Some(out_dir) => out_dir,
+ };
+
+ let out_path = PathBuf::from(out_dir);
+ let mut path = out_path.ancestors().nth(4).unwrap().to_owned();
+ path.push("assets");
+ std::fs::create_dir_all(&path).unwrap();
+
+ let cmd = Cli::command();
+
+ let man = clap_mangen::Man::new(cmd);
+ let mut buffer: Vec<u8> = Default::default();
+ man.render(&mut buffer)?;
+
+ std::fs::write(path.join("hitomezashi-rs.1"), buffer)?;
+
+ Ok(())
+}