1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
|
Description: add build.rs missing from crates.io to build man and completions
Grabbed at commit 4206db397f8ae4161fcfefef23ffa207f3a5a761
Last-Update: 2025-12-06
Index: kmon/build.rs
===================================================================
--- /dev/null
+++ kmon/build.rs
@@ -0,0 +1,50 @@
+#[path = "src/args.rs"]
+mod args;
+
+use clap::ValueEnum;
+use clap_complete::{self, Shell};
+use clap_mangen::Man;
+use std::env;
+use std::error::Error;
+use std::fs::{self, File};
+use std::io::Error as IoError;
+use std::path::{Path, PathBuf};
+
+fn build_shell_completions(out_dir: &Path) -> Result<(), IoError> {
+ fs::create_dir_all(out_dir)?;
+ let mut app = args::get_args();
+ let shells = Shell::value_variants();
+ for shell in shells {
+ clap_complete::generate_to(
+ *shell,
+ &mut app,
+ env!("CARGO_PKG_NAME"),
+ out_dir,
+ )?;
+ }
+ Ok(())
+}
+
+fn build_manpage(out_dir: &Path) -> Result<(), IoError> {
+ fs::create_dir_all(out_dir)?;
+ let app = args::get_args();
+ let file = out_dir.join(concat!(env!("CARGO_PKG_NAME"), ".8"));
+ let mut file = File::create(file)?;
+ Man::new(app).render(&mut file)?;
+ Ok(())
+}
+
+fn main() -> Result<(), Box<dyn Error>> {
+ println!("cargo:rerun-if-changed=src/args.rs");
+ let out_dir = match env::var_os("OUT_DIR").map(PathBuf::from) {
+ None => return Ok(()),
+ Some(v) => v
+ .ancestors()
+ .nth(4)
+ .expect("failed to determine out dir")
+ .to_owned(),
+ };
+ build_manpage(&out_dir.join("man"))?;
+ build_shell_completions(&out_dir.join("completions"))?;
+ Ok(())
+}
Index: kmon/Cargo.toml
===================================================================
--- kmon.orig/Cargo.toml
+++ kmon/Cargo.toml
@@ -14,7 +14,7 @@ edition = "2021"
name = "kmon"
version = "1.7.1"
authors = ["Orhun Parmaksız <orhunparmaksiz@gmail.com>"]
-build = false
+build = "build.rs"
include = [
"src/**/*",
"Cargo.*",
|