feature: make it possible to override generate dirs via env (#1658)

This commit is contained in:
Fotis Gimian 2025-01-19 07:27:24 +11:00 committed by GitHub
parent 1edd8d81ed
commit cf91c73b60
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 4 deletions

View File

@ -38,11 +38,12 @@ fn btm_generate() -> io::Result<()> {
match env::var_os(ENV_KEY) {
Some(var) if !var.is_empty() => {
const COMPLETION_DIR: &str = "./target/tmp/bottom/completion/";
const MANPAGE_DIR: &str = "./target/tmp/bottom/manpage/";
let completion_dir =
option_env!("COMPLETION_DIR").unwrap_or("./target/tmp/bottom/completion/");
let manpage_dir = option_env!("MANPAGE_DIR").unwrap_or("./target/tmp/bottom/manpage/");
let completion_out_dir = PathBuf::from(COMPLETION_DIR);
let manpage_out_dir = PathBuf::from(MANPAGE_DIR);
let completion_out_dir = PathBuf::from(completion_dir);
let manpage_out_dir = PathBuf::from(manpage_dir);
create_dir(&completion_out_dir)?;
create_dir(&manpage_out_dir)?;

View File

@ -54,6 +54,9 @@ This will automatically generate completion and manpage files in `target/tmp/bot
files, modify/delete either these files or set `BTM_GENERATE` to some other non-empty value to retrigger the build
script.
You may override the default diretories used to generate both completion and manpage files by specifying the
`COMPLETION_DIR` and `MANPAGE_DIR` environment variables respectively.
For more information, you may want to look at either the [`build.rs`](https://github.com/ClementTsang/bottom/blob/main/build.rs)
file or the [binary build CI workflow](https://github.com/ClementTsang/bottom/blob/main/.github/workflows/build_releases.yml).