Skip to content

Commit

Permalink
WIP move clap to derive
Browse files Browse the repository at this point in the history
  • Loading branch information
kalil-pelissier committed Dec 13, 2022
1 parent 0f24c9d commit faf977d
Show file tree
Hide file tree
Showing 3 changed files with 121 additions and 11 deletions.
103 changes: 94 additions & 9 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 @@ -43,7 +43,7 @@ byte-unit = { version = "4", default-features = false, features = ["serde"] }
bytes = "1"
chitchat = { git = "https://github.com/quickwit-oss/chitchat", rev = "cd568ba" }
chrono = "0.4.23"
clap = { version = "=3.1", features = ["env"] }
clap = { version = "4.0.29", features = ["env", "derive"] }
colored = "2.0.0"
console-subscriber = "0.1.8"
criterion = { version = "0.4", features = ["async_tokio"] }
Expand Down
27 changes: 26 additions & 1 deletion quickwit/quickwit-cli/src/split.rs
Expand Up @@ -21,7 +21,7 @@ use std::path::PathBuf;
use std::str::FromStr;

use anyhow::{bail, Context};
use clap::{arg, ArgMatches, Command};
use clap::{arg, ArgMatches, Args, Command, Subcommand};
use humansize::{format_size, DECIMAL};
use itertools::Itertools;
use quickwit_common::uri::Uri;
Expand All @@ -37,6 +37,31 @@ use tracing::debug;

use crate::{load_quickwit_config, make_table};

#[derive(Args)]
pub struct SplitCliCommand {
#[command(subcommand)]
command: Option<SplitCliCommands>,
}

#[derive(Subcommand)]
pub enum SplitCliCommands {
/// Lists the splits of an index.
#[command(alias = "ls")]
SplitList(SplitListArgs),
}

#[derive(Args)]
pub struct SplitListArgs {
/// Target index ID
#[arg(long, value_name = "INDEX")]
index: String,

/// Selects the splits whose states are included in this comma-separated list of states.
/// Possible values are `staged`, `published`, and `marked`.
#[arg(long, value_name = "SPLIT_STATES")]
state: Option<Vec<String>>,
}

pub fn build_split_command<'a>() -> Command<'a> {
Command::new("split")
.about("Performs operations on splits (list, describe, mark for deletion, extract).")
Expand Down

0 comments on commit faf977d

Please sign in to comment.