-
-
Notifications
You must be signed in to change notification settings - Fork 204
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(man): add man page generation script (#35)
- Loading branch information
Showing
3 changed files
with
50 additions
and
4 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
use clap::CommandFactory; | ||
use clap_mangen::Man; | ||
use git_cliff::args::Opt; | ||
use std::env; | ||
use std::fs; | ||
use std::io::Result; | ||
use std::path::PathBuf; | ||
|
||
/// Man page can be created with: | ||
/// `cargo run --bin git-cliff-mangen` | ||
/// in a directory specified by the environment variable OUT_DIR. | ||
/// See <https://doc.rust-lang.org/cargo/reference/environment-variables.html> | ||
fn main() -> Result<()> { | ||
let out_dir = env::var("OUT_DIR").expect("OUT_DIR is not set"); | ||
let out_path = | ||
PathBuf::from(out_dir).join(format!("{}.1", env!("CARGO_PKG_NAME"))); | ||
let app = Opt::command(); | ||
let man = Man::new(app); | ||
let mut buffer = Vec::<u8>::new(); | ||
man.render(&mut buffer)?; | ||
fs::write(&out_path, buffer)?; | ||
println!("Man page is generated at {:?}", out_path); | ||
Ok(()) | ||
} |