From 72578d84662a9b9923d52ccde09ac2750d86ae18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20R=C3=BCberg?= Date: Tue, 13 Aug 2024 00:04:06 +0000 Subject: [PATCH 1/3] Remove unneeded dependency --- src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index bc2aaa7..326c659 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,6 +1,6 @@ use std::{ffi::OsString, marker::PhantomData, path::PathBuf, str::FromStr}; -use clap::{Parser, Subcommand}; +use clap::Parser; use console::style; use nu_ansi_term::{Color, Style}; use reedline::{ From 1ae439d0cad40065d2daca425d8d72efe361241e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20R=C3=BCberg?= Date: Tue, 13 Aug 2024 00:04:48 +0000 Subject: [PATCH 2/3] Reexport reedline to prevent version mixups --- examples/simple.rs | 4 +++- src/lib.rs | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/examples/simple.rs b/examples/simple.rs index 57df301..5ce7510 100644 --- a/examples/simple.rs +++ b/examples/simple.rs @@ -1,8 +1,10 @@ use std::path::PathBuf; use clap::{Parser, ValueEnum}; +use clap_repl::reedline::{ + DefaultPrompt, DefaultPromptSegment, FileBackedHistory, Reedline, Signal, +}; use clap_repl::ClapEditor; -use reedline::{DefaultPrompt, DefaultPromptSegment, FileBackedHistory, Reedline, Signal}; #[derive(Debug, Parser)] #[command(name = "")] // This name will show up in clap's error messages, so it is important to set it to "". diff --git a/src/lib.rs b/src/lib.rs index 326c659..0902494 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -3,6 +3,9 @@ use std::{ffi::OsString, marker::PhantomData, path::PathBuf, str::FromStr}; use clap::Parser; use console::style; use nu_ansi_term::{Color, Style}; + +// reexport reedline to prevent version mixups +pub use reedline; use reedline::{ default_emacs_keybindings, DefaultHinter, DefaultPrompt, Emacs, IdeMenu, KeyModifiers, MenuBuilder, Prompt, Reedline, ReedlineEvent, ReedlineMenu, Signal, Span, From cd8bd9af3362843cdeaf262293e752aef4c59707 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20R=C3=BCberg?= Date: Tue, 13 Aug 2024 00:15:48 +0000 Subject: [PATCH 3/3] Update to clap_complete 4.5.16 and enforce exact dependency because of unstable features --- Cargo.toml | 2 +- src/lib.rs | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index fb32a0d..d9e2bf9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,7 +16,7 @@ path = "src/lib.rs" [dependencies] clap = { version = "4.4.10", features = ["derive"] } -clap_complete = { version = "4.5.2", features = ["unstable-dynamic"] } +clap_complete = { version = "=4.5.16", features = ["unstable-dynamic", "unstable-command"] } console = "0.15.7" nu-ansi-term = "0.50.0" reedline = "0.32.0" diff --git a/src/lib.rs b/src/lib.rs index 0902494..c76e27a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,6 +1,6 @@ use std::{ffi::OsString, marker::PhantomData, path::PathBuf, str::FromStr}; -use clap::Parser; +use clap::{Parser, Subcommand}; use console::style; use nu_ansi_term::{Color, Style}; @@ -31,7 +31,7 @@ struct ReedCompleter { impl reedline::Completer for ReedCompleter { fn complete(&mut self, line: &str, pos: usize) -> Vec { let cmd = C::command(); - let mut cmd = clap_complete::dynamic::shells::CompleteCommand::augment_subcommands(cmd); + let mut cmd = clap_complete::dynamic::command::CompleteCommand::augment_subcommands(cmd); let args = Shlex::new(line); let mut args = std::iter::once("".to_owned()) .chain(args) @@ -53,8 +53,8 @@ impl reedline::Completer for ReedCompleter candidates .into_iter() .map(|c| reedline::Suggestion { - value: c.0.to_string_lossy().into_owned(), - description: c.1.map(|x| x.to_string()), + value: c.get_content().to_string_lossy().into_owned(), + description: c.get_help().map(|x| x.to_string()), style: None, extra: None, span,