Skip to content

Commit

Permalink
chore: Simplify build script
Browse files Browse the repository at this point in the history
  • Loading branch information
donovanglover committed Oct 30, 2023
1 parent 0a2a6e1 commit ce57e0c
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,27 @@ use clap::CommandFactory;
use clap_complete::generate_to;
use clap_complete::Shell::{Bash, Fish, Zsh};
use clap_mangen::Man;
use std::fs::{create_dir_all, write};
use std::path::PathBuf;

static NAME: &str = "hyprnome";

fn generate_man_pages(cmd: Command) {
let man_dir = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("target/man");
let man_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("target/man");

std::fs::create_dir_all(&man_dir).unwrap();
create_dir_all(&man_dir).unwrap();

let man = Man::new(cmd);
let mut buffer: Vec<u8> = Default::default();

man.render(&mut buffer).expect("Man page generation failed");
std::fs::write(man_dir.join(NAME.to_owned() + ".1"), buffer).expect("Failed to write man page");
write(man_dir.join(NAME.to_owned() + ".1"), buffer).expect("Failed to write man page");
}

fn generate_shell_completions(mut cmd: Command) {
let comp_dir = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("target/completions");
let comp_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("target/completions");

std::fs::create_dir_all(&comp_dir).unwrap();
create_dir_all(&comp_dir).unwrap();

for shell in [Bash, Fish, Zsh] {
generate_to(shell, &mut cmd, NAME, &comp_dir).unwrap();
Expand Down

0 comments on commit ce57e0c

Please sign in to comment.