123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- fn main() {
- #[cfg(feature = "cli")]
- cli::main();
- }
- #[cfg(feature = "cli")]
- mod cli {
- include!("src/cli.rs");
- use sc_cli::structopt::clap::Shell;
- use std::{env, fs, path::Path};
- use substrate_build_script_utils::{generate_cargo_keys, rerun_if_git_head_changed};
- pub fn main() {
- build_shell_completion();
- generate_cargo_keys();
- rerun_if_git_head_changed();
- }
-
-
- fn build_shell_completion() {
- for shell in &[
- Shell::Bash,
- Shell::Fish,
- Shell::Zsh,
- Shell::Elvish,
- Shell::PowerShell,
- ] {
- build_completion(shell);
- }
- }
-
- fn build_completion(shell: &Shell) {
- let outdir = match env::var_os("OUT_DIR") {
- None => return,
- Some(dir) => dir,
- };
- let path = Path::new(&outdir)
- .parent()
- .unwrap()
- .parent()
- .unwrap()
- .parent()
- .unwrap()
- .join("completion-scripts");
- fs::create_dir(&path).ok();
- Cli::clap().gen_completions("joystream-node", *shell, &path);
- }
- }
|