Skip to content

Commit

Permalink
refactor: Resolve deprecations
Browse files Browse the repository at this point in the history
  • Loading branch information
epage committed Jul 26, 2024
1 parent 82912c3 commit 9c6ef3e
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
3 changes: 2 additions & 1 deletion clap_complete/src/dynamic/shells/bash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ impl crate::dynamic::Completer for Bash {
let mut upper_name = escaped_name.clone();
upper_name.make_ascii_uppercase();

let completer = shlex::quote(completer);
let completer =
shlex::try_quote(completer).unwrap_or(std::borrow::Cow::Borrowed(completer));

let script = r#"
_clap_complete_NAME() {
Expand Down
5 changes: 3 additions & 2 deletions clap_complete/src/dynamic/shells/elvish.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ impl crate::dynamic::Completer for Elvish {
completer: &str,
buf: &mut dyn std::io::Write,
) -> Result<(), std::io::Error> {
let bin = shlex::quote(bin);
let completer = shlex::quote(completer);
let bin = shlex::try_quote(bin).unwrap_or(std::borrow::Cow::Borrowed(bin));
let completer =
shlex::try_quote(completer).unwrap_or(std::borrow::Cow::Borrowed(completer));

let script = r#"
set edit:completion:arg-completer[BIN] = { |@words|
Expand Down
6 changes: 4 additions & 2 deletions clap_complete/src/dynamic/shells/fish.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ impl crate::dynamic::Completer for Fish {
completer: &str,
buf: &mut dyn std::io::Write,
) -> Result<(), std::io::Error> {
let bin = shlex::quote(bin);
let completer = shlex::quote(completer);
let bin = shlex::try_quote(bin).unwrap_or(std::borrow::Cow::Borrowed(bin));
let completer =
shlex::try_quote(completer).unwrap_or(std::borrow::Cow::Borrowed(completer));

writeln!(
buf,
r#"complete -x -c {bin} -a "("'{completer}'" complete --shell fish -- (commandline --current-process --tokenize --cut-at-cursor) (commandline --current-token))""#
Expand Down
6 changes: 4 additions & 2 deletions clap_complete/src/dynamic/shells/zsh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ impl crate::dynamic::Completer for Zsh {
completer: &str,
buf: &mut dyn std::io::Write,
) -> Result<(), std::io::Error> {
let bin = shlex::quote(bin);
let completer = shlex::quote(completer);
let bin = shlex::try_quote(bin).unwrap_or(std::borrow::Cow::Borrowed(bin));
let completer =
shlex::try_quote(completer).unwrap_or(std::borrow::Cow::Borrowed(completer));

let script = r#"#compdef BIN
function _clap_dynamic_completer() {
export _CLAP_COMPLETE_INDEX=$(expr $CURRENT - 1)
Expand Down

0 comments on commit 9c6ef3e

Please sign in to comment.