Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgraded clap to v4 #3209

Merged
merged 4 commits into from May 17, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
92 changes: 86 additions & 6 deletions quickwit/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion quickwit/Cargo.toml
Expand Up @@ -52,7 +52,7 @@ byte-unit = { version = "4", default-features = false, features = ["serde"] }
bytes = "1"
chitchat = { git = "https://github.com/quickwit-oss/chitchat", rev = "4973853" }
chrono = "0.4.23"
clap = { version = "=3.1", features = ["env"] }
clap = { version = "4.2.4", features = ["env", "string"] }
colored = "2.0.0"
console-subscriber = "0.1.8"
criterion = { version = "0.4", features = ["async_tokio"] }
Expand Down
3 changes: 2 additions & 1 deletion quickwit/quickwit-actors/src/actor.rs
Expand Up @@ -227,7 +227,8 @@ pub trait Handler<M>: Actor {

#[async_trait::async_trait]
impl<H, M> DeferableReplyHandler<M> for H
where H: Handler<M>
where
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use make fmt to format your changes according to our code style. It requires the nightly toolchain.

H: Handler<M>,
{
type Reply = H::Reply;

Expand Down
4 changes: 3 additions & 1 deletion quickwit/quickwit-actors/src/actor_context.rs
Expand Up @@ -146,7 +146,9 @@ impl<A: Actor> ActorContext<A> {

/// Executes a future in a protected zone.
pub async fn protect_future<Fut, T>(&self, future: Fut) -> T
where Fut: Future<Output = T> {
where
Fut: Future<Output = T>,
{
let _guard = self.protect_zone();
future.await
}
Expand Down
6 changes: 3 additions & 3 deletions quickwit/quickwit-cli/src/cli.rs
Expand Up @@ -18,7 +18,7 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.

use anyhow::bail;
use clap::{arg, Arg, ArgMatches, Command};
use clap::{arg, Arg, ArgAction, ArgMatches, Command};
use tracing::Level;

use crate::index::{build_index_command, IndexCliCommand};
Expand All @@ -27,7 +27,7 @@ use crate::source::{build_source_command, SourceCliCommand};
use crate::split::{build_split_command, SplitCliCommand};
use crate::tool::{build_tool_command, ToolCliCommand};

pub fn build_cli<'a>() -> Command<'a> {
pub fn build_cli() -> Command {
Command::new("Quickwit")
.arg(
Arg::new("no-color")
Expand All @@ -38,7 +38,7 @@ pub fn build_cli<'a>() -> Command<'a> {
)
.env("NO_COLOR")
.global(true)
.takes_value(false),
.action(ArgAction::SetFalse),
)
.arg(arg!(-y --"yes" "Assume \"yes\" as an answer to all prompts and run non-interactively.")
.global(true)
Expand Down
8 changes: 4 additions & 4 deletions quickwit/quickwit-cli/src/generate_markdown.rs
Expand Up @@ -31,7 +31,7 @@ async fn main() -> anyhow::Result<()> {
);

let app = build_cli()
.version(version_text.as_str())
.version(version_text)
.disable_help_subcommand(true);

generate_markdown_from_clap(&app);
Expand Down Expand Up @@ -91,7 +91,7 @@ fn markdown_for_command_helper(
println!("{about} ");
}
} else if let Some(about) = subcommand.get_about() {
if !about.trim().is_empty() {
if !about.to_string().trim().is_empty() {
println!("{about} ");
}
}
Expand Down Expand Up @@ -122,7 +122,7 @@ fn markdown_for_command_helper(
println!("quickwit {command_name}");
for arg in &arguments {
let is_required = arg.is_required_set();
let is_bool = !arg.is_takes_value_set();
let is_bool = !arg.get_action().takes_values();

let mut commando = format!("--{}", arg.get_id());
if !is_bool {
Expand Down Expand Up @@ -172,7 +172,7 @@ fn generate_markdown_from_clap(command: &Command) {
let command_name = command.get_name(); // index, split, source
println!("## {command_name}");
if let Some(about) = command.get_long_about().or_else(|| command.get_about()) {
if !about.trim().is_empty() {
if !about.to_string().trim().is_empty() {
println!("{about}\n");
}
}
Expand Down