-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7924653
commit 0931e71
Showing
3 changed files
with
71 additions
and
10 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,48 @@ | ||
use polkadot_sdk::substrate_build_script_utils::{generate_cargo_keys, rerun_if_git_head_changed}; | ||
|
||
fn main() { | ||
generate_cargo_keys(); | ||
cli::main(); | ||
} | ||
|
||
mod cli { | ||
include!("src/cli.rs"); | ||
|
||
use clap::{CommandFactory, ValueEnum}; | ||
use clap_complete::{generate_to, Shell}; | ||
use polkadot_sdk::substrate_build_script_utils::{ | ||
generate_cargo_keys, rerun_if_git_head_changed, | ||
}; | ||
use std::{env, fs, path::Path}; | ||
|
||
pub fn main() { | ||
build_shell_completion(); | ||
generate_cargo_keys(); | ||
|
||
rerun_if_git_head_changed(); | ||
} | ||
|
||
/// Build shell completion scripts for all known shells. | ||
fn build_shell_completion() { | ||
for shell in Shell::value_variants() { | ||
build_completion(shell); | ||
} | ||
} | ||
|
||
/// Build the shell auto-completion for a given 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(); | ||
|
||
rerun_if_git_head_changed(); | ||
let _ = generate_to(*shell, &mut Cli::command(), "timechain-node", &path); | ||
} | ||
} |