2021-02-10 01:19:34 +03:00
|
|
|
use directories_next::ProjectDirs;
|
2021-02-23 23:27:22 +03:00
|
|
|
use std::{ffi::OsStr, fs};
|
2021-02-10 01:19:34 +03:00
|
|
|
use structopt::clap::Shell;
|
|
|
|
use walkdir::WalkDir;
|
|
|
|
|
|
|
|
include!("src/cli.rs");
|
|
|
|
|
|
|
|
const BIN_NAME: &str = "zellij";
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
// Generate Shell Completions
|
|
|
|
let mut clap_app = CliArgs::clap();
|
|
|
|
println!("cargo:rerun-if-changed=src/cli.rs");
|
|
|
|
let mut out_dir = std::env::var_os("CARGO_MANIFEST_DIR").unwrap();
|
|
|
|
out_dir.push("/assets/completions");
|
|
|
|
|
|
|
|
println!(
|
|
|
|
"Completion files will to added to this location: {:?}",
|
|
|
|
out_dir
|
|
|
|
);
|
|
|
|
fs::create_dir_all(&out_dir).unwrap();
|
|
|
|
clap_app.gen_completions(BIN_NAME, Shell::Bash, &out_dir);
|
|
|
|
clap_app.gen_completions(BIN_NAME, Shell::Zsh, &out_dir);
|
|
|
|
clap_app.gen_completions(BIN_NAME, Shell::Fish, &out_dir);
|
2021-02-16 21:33:27 +03:00
|
|
|
|
|
|
|
// Clear Default Plugins and Layouts
|
2021-02-23 23:27:22 +03:00
|
|
|
|
|
|
|
// Rerun on layout change
|
2021-02-23 19:10:38 +03:00
|
|
|
for entry in WalkDir::new("assets/layouts") {
|
2021-02-16 21:33:27 +03:00
|
|
|
let entry = entry.unwrap();
|
2021-02-16 23:30:16 +03:00
|
|
|
println!("cargo:rerun-if-changed={}", entry.path().to_string_lossy());
|
2021-02-16 21:33:27 +03:00
|
|
|
}
|
|
|
|
|
2021-02-23 23:27:22 +03:00
|
|
|
// Rerun on plugin change
|
2021-02-26 12:27:59 +03:00
|
|
|
#[cfg(not(feature = "publish"))]
|
|
|
|
let plugin_dir = "target";
|
|
|
|
#[cfg(feature = "publish")]
|
|
|
|
let plugin_dir = "assets/plugins";
|
|
|
|
for entry in WalkDir::new(plugin_dir) {
|
2021-02-23 23:27:22 +03:00
|
|
|
let entry = entry.unwrap();
|
|
|
|
if entry.path().extension() == Some(OsStr::new("wasm")) {
|
|
|
|
println!("cargo:rerun-if-changed={}", entry.path().to_string_lossy());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-02-16 21:33:27 +03:00
|
|
|
let project_dirs = ProjectDirs::from("org", "Zellij Contributors", "Zellij").unwrap();
|
|
|
|
let data_dir = project_dirs.data_dir();
|
|
|
|
drop(fs::remove_file(data_dir.join("plugins/status-bar.wasm")));
|
2021-02-21 02:19:05 +03:00
|
|
|
drop(fs::remove_file(data_dir.join("plugins/tab-bar.wasm")));
|
2021-02-16 21:33:27 +03:00
|
|
|
drop(fs::remove_file(data_dir.join("plugins/strider.wasm")));
|
|
|
|
drop(fs::remove_file(data_dir.join("layouts/default.yaml")));
|
|
|
|
drop(fs::remove_file(data_dir.join("layouts/strider.yaml")));
|
2021-02-10 01:19:34 +03:00
|
|
|
}
|