-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add compile time completion generation
- Loading branch information
1 parent
cf5ad2a
commit c87bf2a
Showing
10 changed files
with
4,741 additions
and
3 deletions.
There are no files selected for viewing
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,33 @@ | ||
#[cfg(feature = "completions")] | ||
mod completions { | ||
#[path = "../src/parse.rs"] | ||
mod parse; | ||
|
||
use clap::{CommandFactory, ValueEnum}; | ||
use clap_complete::{generate_to, shells::Shell}; | ||
use clap_complete_nushell::Nushell; | ||
use std::io::Error; | ||
|
||
pub fn generate_completions() -> Result<(), Error> { | ||
let out_dir = "completions"; | ||
let bin_name = "perseus"; | ||
// on windows, bin_name is "perseus.exe" | ||
#[cfg(windows)] | ||
let bin_name = "perseus.exe"; | ||
|
||
let mut cmd = parse::Opts::command(); | ||
|
||
for shell in Shell::value_variants() { | ||
generate_to(*shell, &mut cmd, bin_name, out_dir)?; | ||
} | ||
generate_to(Nushell, &mut cmd, bin_name, out_dir)?; | ||
|
||
Ok(()) | ||
} | ||
} | ||
|
||
fn main() -> Result<(), Box<dyn std::error::Error>> { | ||
#[cfg(feature = "completions")] | ||
completions::generate_completions()?; | ||
Ok(()) | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.