Skip to content

Commit

Permalink
feat(build): add cargo deps and build.rs for mangen poc
Browse files Browse the repository at this point in the history
Signed-off-by: Sandro-Alessio Gierens <sandro@gierens.de>
  • Loading branch information
gierens committed Sep 17, 2023
1 parent 2270865 commit 2907772
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,7 @@ lazy_static = "1.4"
serial_test = "2.0"
# cli
trycmd = "0.14"

[build-dependencies]
clap_mangen = { version = "0.2.13" }
clap = { version = "4.4", features = ["derive", "env"] }
22 changes: 22 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#[allow(dead_code)]
fn mangen() -> std::io::Result<()> {
let out_dir = std::path::PathBuf::from(std::env::var_os("OUT_DIR").ok_or(std::io::ErrorKind::NotFound)?);

let cmd = clap::Command::new("wikijs")
.arg(clap::arg!(-u --url <URL>));
// .arg(clap::arg!(-c --count <NUM>));

let man = clap_mangen::Man::new(cmd);
let mut buffer: Vec<u8> = Default::default();
man.render(&mut buffer)?;

std::fs::write(out_dir.join("wikijs.1"), buffer)?;

Ok(())
}

fn main() -> std::io::Result<()> {
#[cfg(feature = "cli")]
mangen()?;
Ok(())
}

0 comments on commit 2907772

Please sign in to comment.