aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Cargo.lock17
-rw-r--r--Cargo.toml4
-rw-r--r--build.rs45
-rw-r--r--hitomezashi-rs.123
4 files changed, 66 insertions, 23 deletions
diff --git a/Cargo.lock b/Cargo.lock
index d72fd7c..082dc8e 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -97,6 +97,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "98cc8fbded0c607b7ba9dd60cd98df59af97e84d24e49c8557331cfc26d301ce"
[[package]]
+name = "clap_mangen"
+version = "0.2.20"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e1dd95b5ebb5c1c54581dd6346f3ed6a79a3eef95dd372fc2ac13d535535300e"
+dependencies = [
+ "clap",
+ "roff",
+]
+
+[[package]]
name = "colorchoice"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -134,6 +144,7 @@ name = "hitomezashi-rs"
version = "3.0.0"
dependencies = [
"clap",
+ "clap_mangen",
"colored",
"rand",
]
@@ -205,6 +216,12 @@ dependencies = [
]
[[package]]
+name = "roff"
+version = "0.2.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b833d8d034ea094b1ea68aa6d5c740e0d04bad9d16568d08ba6f76823a114316"
+
+[[package]]
name = "strsim"
version = "0.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
diff --git a/Cargo.toml b/Cargo.toml
index b6a3523..93b8bd7 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -15,3 +15,7 @@ exclude = [
clap = { version = "4.5.3", features = ["derive"] }
colored = "2.1.0"
rand = "0.8.5"
+
+[build-dependencies]
+clap = { version = "4.5.3", features = ["derive"] }
+clap_mangen = "0.2.20"
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(())
+}
diff --git a/hitomezashi-rs.1 b/hitomezashi-rs.1
deleted file mode 100644
index 7ad5fc0..0000000
--- a/hitomezashi-rs.1
+++ /dev/null
@@ -1,23 +0,0 @@
-.TH HITOMEZASHI-RS "1" "April 2024" "hitomezashi-rs v3.0.0"
-.SH NAME
-hitomezashi-rs \- generates classic two-colored Hitomezashi stitch patterns.
-.SH SYNOPSIS
-hitomezashi-rs <WIDTH> <HEIGHT>
-.SH DESCRIPTION
-Hitomezashi-rs is a fast, portable generator of classic, two-colored Hitomezashi stitch patterns.
-
-A classic Hitomezashi stitch pattern consists of dashed horizontal and vertical lines which form random patterns. This program outputs the two-colored version of those patterns.
-.SH OPTIONS
-\-h, \-\-help
-.TP
-\-v, \-\-version
-.TP
-\-s, \-\-skew <number from 0 to 1 inclusive>
-.RS 4
-The closer the skew value is to 0 or 1, the more orderly the patterns. The default skew value is 0.5, the value that yields the most disordered patterns.
-.SH AUTHOR
-Written by Nicholas Johnson.
-.SH REPORTING BUGS
-Report bugs to nick@nicholasjohnson.ch
-.SH COPYRIGHT
-Copyright © 2024 Nicholas Johnson. License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>. This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.