2021-01-12 02:00:19 +03:00
|
|
|
use directories_next::ProjectDirs;
|
|
|
|
use std::{fs, path::Path};
|
2021-01-07 12:44:28 +03:00
|
|
|
use structopt::clap::Shell;
|
|
|
|
|
|
|
|
include!("src/cli.rs");
|
|
|
|
|
|
|
|
const BIN_NAME: &str = "mosaic";
|
|
|
|
|
|
|
|
fn main() {
|
2021-01-12 02:00:19 +03:00
|
|
|
// Generate Shell Completions
|
2021-01-07 12:44:28 +03:00
|
|
|
let mut clap_app = CliArgs::clap();
|
2021-01-12 02:00:19 +03:00
|
|
|
println!("cargo:rerun-if-changed=src/cli.rs");
|
2021-01-07 19:21:38 +03:00
|
|
|
let mut out_dir = std::env::var_os("CARGO_MANIFEST_DIR").unwrap();
|
2021-01-07 12:44:28 +03:00
|
|
|
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-01-12 02:00:19 +03:00
|
|
|
|
|
|
|
// Install Default Plugins and Layouts
|
|
|
|
let assets = vec![
|
|
|
|
"plugins/status-bar.wasm",
|
|
|
|
"plugins/strider.wasm",
|
|
|
|
"layouts/default.yaml",
|
|
|
|
"layouts/strider.yaml",
|
|
|
|
];
|
|
|
|
let project_dirs = ProjectDirs::from("org", "Mosaic Contributors", "Mosaic").unwrap();
|
|
|
|
let data_dir = project_dirs.data_dir();
|
|
|
|
fs::create_dir_all(data_dir.join("plugins")).unwrap();
|
|
|
|
fs::create_dir_all(data_dir.join("layouts")).unwrap();
|
|
|
|
for asset in assets {
|
|
|
|
println!("cargo:rerun-if-changed=assets/{}", asset);
|
|
|
|
fs::copy(Path::new("assets/").join(asset), data_dir.join(asset))
|
|
|
|
.expect("Failed to copy asset files");
|
|
|
|
}
|
2021-01-07 12:44:28 +03:00
|
|
|
}
|