-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rust: Generate shell (e.g. bash) completion scripts via build.rs for …
…all tools It might be handy to have shell completion support for the Rust PV tools. Reviewed-by: Steffen Eiden <[email protected]> Signed-off-by: Marc Hartmayer <[email protected]> Signed-off-by: Steffen Eiden <[email protected]>
- Loading branch information
1 parent
4d2c92f
commit f83af8e
Showing
7 changed files
with
104 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// SPDX-License-Identifier: MIT | ||
// | ||
// Copyright IBM Corp. 2024 | ||
// it under the terms of the MIT license. See LICENSE for details. | ||
|
||
use clap::{CommandFactory, ValueEnum}; | ||
use clap_complete::{generate_to, Shell}; | ||
use std::env; | ||
use std::io::Error; | ||
|
||
include!("src/cli.rs"); | ||
|
||
fn main() -> Result<(), Error> { | ||
let outdir = env::var_os("OUT_DIR").unwrap(); | ||
let crate_name = env!("CARGO_PKG_NAME"); | ||
let mut cmd = Cli::command(); | ||
for &shell in Shell::value_variants() { | ||
generate_to(shell, &mut cmd, crate_name, &outdir)?; | ||
} | ||
|
||
println!("cargo:rerun-if-changed=build.rs"); | ||
println!("cargo:rerun-if-changed=src/cli.rs"); | ||
Ok(()) | ||
} |
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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// SPDX-License-Identifier: MIT | ||
// | ||
// Copyright IBM Corp. 2024 | ||
// it under the terms of the MIT license. See LICENSE for details. | ||
|
||
use clap::CommandFactory; | ||
use clap_complete::{generate_to, Shell}; | ||
use std::env; | ||
use std::io::Error; | ||
|
||
include!("src/cli.rs"); | ||
|
||
fn main() -> Result<(), Error> { | ||
let outdir = env::var_os("OUT_DIR").unwrap(); | ||
let crate_name = env!("CARGO_PKG_NAME"); | ||
let mut cmd = CliOptions::command(); | ||
for &shell in Shell::value_variants() { | ||
generate_to(shell, &mut cmd, crate_name, &outdir)?; | ||
} | ||
|
||
println!("cargo:rerun-if-changed=build.rs"); | ||
println!("cargo:rerun-if-changed=src/cli.rs"); | ||
println!("cargo:rerun-if-changed=../utils/src/cli.rs"); | ||
Ok(()) | ||
} |
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// SPDX-License-Identifier: MIT | ||
// | ||
// Copyright IBM Corp. 2024 | ||
// it under the terms of the MIT license. See LICENSE for details. | ||
|
||
use clap_complete::{generate_to, Shell}; | ||
use std::env; | ||
use std::io::Error; | ||
|
||
include!("src/cli.rs"); | ||
|
||
fn main() -> Result<(), Error> { | ||
let outdir = env::var_os("OUT_DIR").unwrap(); | ||
let crate_name = env!("CARGO_PKG_NAME"); | ||
let mut cmd = CliOptions::command(); | ||
for &shell in Shell::value_variants() { | ||
generate_to(shell, &mut cmd, crate_name, &outdir)?; | ||
} | ||
|
||
println!("cargo:rerun-if-changed=build.rs"); | ||
println!("cargo:rerun-if-changed=src/cli.rs"); | ||
println!("cargo:rerun-if-changed=../utils/src/cli.rs"); | ||
Ok(()) | ||
} |