diff --git a/Cargo.toml b/Cargo.toml index 098e8b8..41ac780 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,22 +4,20 @@ categories = ["command-line-utilities"] description = "Replace with description" documentation = "https://docs.rs/arrow_cli" repository = "https://github.com/sundy-li/arrow_cli" -edition = "2021" +edition = "2024" license = "Apache-2.0" name = "arrow_cli" -version = "0.1.3" - +version = "0.2.0" [dependencies] -shlex = "1.1.0" atty = "0.2" -rustyline = "11.0.0" -arrow-cast = { version = "51", features = ["prettyprint"] } -arrow-flight = { version = "51", features = ["flight-sql-experimental"] } -arrow = { version = "51", features = ["ipc_compression"] } +rustyline = "15" +arrow-cast = { version = "55", features = ["prettyprint"] } +arrow-flight = { version = "55", features = ["flight-sql-experimental"] } +arrow = { version = "55", features = ["ipc_compression"] } futures = { version = "0.3", default-features = false, features = ["alloc"] } -tokio = { version = "1.26", features = [ +tokio = { version = "1", features = [ "macros", "rt", "rt-multi-thread", @@ -27,10 +25,10 @@ tokio = { version = "1.26", features = [ "parking_lot", ] } -tonic = { version = "0.11", default-features = false, features = [ +tonic = { version = "0.12", default-features = false, features = [ "transport", "codegen", "tls", "prost", ] } -clap = { version = "4.1.0", features = ["derive"] } +clap = { version = "4.5", features = ["derive"] } diff --git a/src/helper.rs b/src/helper.rs index 992507a..8957d9d 100644 --- a/src/helper.rs +++ b/src/helper.rs @@ -20,18 +20,18 @@ use std::borrow::Cow; +use rustyline::Context; +use rustyline::Helper; +use rustyline::Result; use rustyline::completion::Completer; use rustyline::completion::FilenameCompleter; use rustyline::completion::Pair; use rustyline::error::ReadlineError; -use rustyline::highlight::Highlighter; +use rustyline::highlight::{CmdKind, Highlighter}; use rustyline::hint::Hinter; use rustyline::validate::ValidationContext; use rustyline::validate::ValidationResult; use rustyline::validate::Validator; -use rustyline::Context; -use rustyline::Helper; -use rustyline::Result; pub struct CliHelper { completer: FilenameCompleter, @@ -78,25 +78,25 @@ impl Highlighter for CliHelper { &'s self, prompt: &'p str, default: bool, - ) -> std::borrow::Cow<'b, str> { + ) -> Cow<'b, str> { let _ = default; - std::borrow::Cow::Borrowed(prompt) + Cow::Borrowed(prompt) } fn highlight_hint<'h>(&self, hint: &'h str) -> std::borrow::Cow<'h, str> { - std::borrow::Cow::Owned("\x1b[1m".to_owned() + hint + "\x1b[m") + Cow::Owned("\x1b[1m".to_owned() + hint + "\x1b[m") } fn highlight_candidate<'c>( &self, candidate: &'c str, // FIXME should be Completer::Candidate completion: rustyline::CompletionType, - ) -> std::borrow::Cow<'c, str> { + ) -> Cow<'c, str> { let _ = completion; - std::borrow::Cow::Borrowed(candidate) + Cow::Borrowed(candidate) } - fn highlight_char(&self, line: &str, _pos: usize) -> bool { + fn highlight_char(&self, line: &str, _pos: usize, _kind: CmdKind) -> bool { !line.is_empty() } } @@ -187,7 +187,10 @@ static KEYWORDS: &str = include_str!("keywords.txt"); impl KeyWordCompleter { fn complete(s: &str, pos: usize) -> (usize, Vec) { - let hint = s.split(|p: char| p.is_whitespace()).last().unwrap_or(s); + let hint = s + .split(|p: char| p.is_whitespace()) + .next_back() + .unwrap_or(s); let res: (usize, Vec) = ( pos - hint.len(), KEYWORDS diff --git a/src/main.rs b/src/main.rs index c93ad20..b51f1a9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -38,6 +38,9 @@ struct Args { #[clap(long, help = "Print help information")] help: bool, + + #[clap(long, default_value = "180", help = "Request timeout in seconds")] + timeout: u64, } #[tokio::main] @@ -61,8 +64,7 @@ pub async fn main() -> Result<(), ArrowError> { } fn print_usage() { - let msg = - r#"Usage: arrow_cli <--user |--password |--host |--port >"#; + let msg = r#"Usage: arrow_cli <--user |--password |--host |--port |--timeout