Skip to content

Commit

Permalink
Merge pull request #5685 from epage/engine
Browse files Browse the repository at this point in the history
fix(complete)!: Rename dynamic to engine
  • Loading branch information
epage authored Aug 19, 2024
2 parents 232af62 + b38538d commit 8b3de18
Show file tree
Hide file tree
Showing 10 changed files with 186 additions and 84 deletions.
6 changes: 3 additions & 3 deletions clap_complete/src/command/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ impl CompleteArgs {
///
/// This will generally be called by [`CompleteCommand`] or [`CompleteArgs`].
///
/// This handles adapting between the shell and [`completer`][crate::dynamic::complete()].
/// This handles adapting between the shell and [`completer`][crate::engine::complete()].
/// A `CommandCompleter` can choose how much of that lives within the registration script and or
/// lives in [`CommandCompleter::write_complete`].
pub trait CommandCompleter {
Expand All @@ -238,9 +238,9 @@ pub trait CommandCompleter {
/// Complete the given command
///
/// Adapt information from arguments and [`CommandCompleter::write_registration`]-defined env
/// variables to what is needed for [`completer`][crate::dynamic::complete()].
/// variables to what is needed for [`completer`][crate::engine::complete()].
///
/// Write out the [`CompletionCandidate`][crate::dynamic::CompletionCandidate]s in a way the shell will understand.
/// Write out the [`CompletionCandidate`][crate::engine::CompletionCandidate]s in a way the shell will understand.
fn write_complete(
&self,
cmd: &mut clap::Command,
Expand Down
10 changes: 5 additions & 5 deletions clap_complete/src/command/shells.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ fi
.ok()
.and_then(|i| i.parse().ok());
let ifs: Option<String> = std::env::var("IFS").ok().and_then(|i| i.parse().ok());
let completions = crate::dynamic::complete(cmd, args, index, current_dir)?;
let completions = crate::engine::complete(cmd, args, index, current_dir)?;

for (i, candidate) in completions.iter().enumerate() {
if i != 0 {
Expand Down Expand Up @@ -335,7 +335,7 @@ set edit:completion:arg-completer[BIN] = { |@words|
.and_then(|i| i.parse().ok())
.unwrap_or_default();
let ifs: Option<String> = std::env::var("_CLAP_IFS").ok().and_then(|i| i.parse().ok());
let completions = crate::dynamic::complete(cmd, args, index, current_dir)?;
let completions = crate::engine::complete(cmd, args, index, current_dir)?;

for (i, candidate) in completions.iter().enumerate() {
if i != 0 {
Expand Down Expand Up @@ -376,7 +376,7 @@ impl CommandCompleter for Fish {
buf: &mut dyn std::io::Write,
) -> Result<(), std::io::Error> {
let index = args.len() - 1;
let completions = crate::dynamic::complete(cmd, args, index, current_dir)?;
let completions = crate::engine::complete(cmd, args, index, current_dir)?;

for candidate in completions {
write!(buf, "{}", candidate.get_content().to_string_lossy())?;
Expand Down Expand Up @@ -442,7 +442,7 @@ Register-ArgumentCompleter -Native -CommandName {bin} -ScriptBlock {{
buf: &mut dyn std::io::Write,
) -> Result<(), std::io::Error> {
let index = args.len() - 1;
let completions = crate::dynamic::complete(cmd, args, index, current_dir)?;
let completions = crate::engine::complete(cmd, args, index, current_dir)?;

for candidate in completions {
write!(buf, "{}", candidate.get_content().to_string_lossy())?;
Expand Down Expand Up @@ -516,7 +516,7 @@ compdef _clap_dynamic_completer BIN"#
if args.len() == index {
args.push("".into());
}
let completions = crate::dynamic::complete(cmd, args, index, current_dir)?;
let completions = crate::engine::complete(cmd, args, index, current_dir)?;

for (i, candidate) in completions.iter().enumerate() {
if i != 0 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ impl CompletionCandidate {

/// Add a prefix to the content of completion candidate
///
/// This is generally used for post-process by [`complete`][crate::dynamic::complete()] for
/// This is generally used for post-process by [`complete`][crate::engine::complete()] for
/// things like pre-pending flags, merging delimiter-separated values, etc.
pub fn add_prefix(mut self, prefix: impl Into<OsString>) -> Self {
let suffix = self.content;
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use super::CompletionCandidate;
///
/// ```rust
/// use clap::Parser;
/// use clap_complete::dynamic::{ArgValueCompleter, CompletionCandidate};
/// use clap_complete::engine::{ArgValueCompleter, CompletionCandidate};
///
/// #[derive(Debug, Parser)]
/// struct Cli {
Expand Down
File renamed without changes.
6 changes: 3 additions & 3 deletions clap_complete/src/env/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ impl<'s> Shells<'s> {
///
/// This will generally be called by [`CompleteEnv`].
///
/// This handles adapting between the shell and [`completer`][crate::dynamic::complete()].
/// This handles adapting between the shell and [`completer`][crate::engine::complete()].
/// A `EnvCompleter` can choose how much of that lives within the registration script or
/// lives in [`EnvCompleter::write_complete`].
pub trait EnvCompleter {
Expand Down Expand Up @@ -308,9 +308,9 @@ pub trait EnvCompleter {
/// Complete the given command
///
/// Adapt information from arguments and [`EnvCompleter::write_registration`]-defined env
/// variables to what is needed for [`completer`][crate::dynamic::complete()].
/// variables to what is needed for [`completer`][crate::engine::complete()].
///
/// Write out the [`CompletionCandidate`][crate::dynamic::CompletionCandidate]s in a way the shell will understand.
/// Write out the [`CompletionCandidate`][crate::engine::CompletionCandidate]s in a way the shell will understand.
fn write_complete(
&self,
cmd: &mut clap::Command,
Expand Down
10 changes: 5 additions & 5 deletions clap_complete/src/env/shells.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ fi
.ok()
.and_then(|i| i.parse().ok());
let ifs: Option<String> = std::env::var("IFS").ok().and_then(|i| i.parse().ok());
let completions = crate::dynamic::complete(cmd, args, index, current_dir)?;
let completions = crate::engine::complete(cmd, args, index, current_dir)?;

for (i, candidate) in completions.iter().enumerate() {
if i != 0 {
Expand Down Expand Up @@ -189,7 +189,7 @@ set edit:completion:arg-completer[BIN] = { |@words|
.and_then(|i| i.parse().ok())
.unwrap_or_default();
let ifs: Option<String> = std::env::var("_CLAP_IFS").ok().and_then(|i| i.parse().ok());
let completions = crate::dynamic::complete(cmd, args, index, current_dir)?;
let completions = crate::engine::complete(cmd, args, index, current_dir)?;

for (i, candidate) in completions.iter().enumerate() {
if i != 0 {
Expand Down Expand Up @@ -237,7 +237,7 @@ impl EnvCompleter for Fish {
buf: &mut dyn std::io::Write,
) -> Result<(), std::io::Error> {
let index = args.len() - 1;
let completions = crate::dynamic::complete(cmd, args, index, current_dir)?;
let completions = crate::engine::complete(cmd, args, index, current_dir)?;

for candidate in completions {
write!(buf, "{}", candidate.get_content().to_string_lossy())?;
Expand Down Expand Up @@ -310,7 +310,7 @@ Register-ArgumentCompleter -Native -CommandName {bin} -ScriptBlock {{
buf: &mut dyn std::io::Write,
) -> Result<(), std::io::Error> {
let index = args.len() - 1;
let completions = crate::dynamic::complete(cmd, args, index, current_dir)?;
let completions = crate::engine::complete(cmd, args, index, current_dir)?;

for candidate in completions {
write!(buf, "{}", candidate.get_content().to_string_lossy())?;
Expand Down Expand Up @@ -393,7 +393,7 @@ compdef _clap_dynamic_completer BIN"#
if args.len() == index {
args.push("".into());
}
let completions = crate::dynamic::complete(cmd, args, index, current_dir)?;
let completions = crate::engine::complete(cmd, args, index, current_dir)?;

for (i, candidate) in completions.iter().enumerate() {
if i != 0 {
Expand Down
6 changes: 3 additions & 3 deletions clap_complete/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ pub mod aot;
#[cfg(feature = "unstable-command")]
pub mod command;
#[cfg(feature = "unstable-dynamic")]
pub mod dynamic;
pub mod engine;
#[cfg(feature = "unstable-dynamic")]
pub mod env;

Expand All @@ -80,10 +80,10 @@ pub use command::CompleteArgs;
pub use command::CompleteCommand;
#[doc(inline)]
#[cfg(feature = "unstable-dynamic")]
pub use dynamic::ArgValueCompleter;
pub use engine::ArgValueCompleter;
#[doc(inline)]
#[cfg(feature = "unstable-dynamic")]
pub use dynamic::CompletionCandidate;
pub use engine::CompletionCandidate;
#[cfg(feature = "unstable-dynamic")]
pub use env::CompleteEnv;

Expand Down
Loading

0 comments on commit 8b3de18

Please sign in to comment.