Skip to content

Commit cc88afa

Browse files
author
Jackson Newhouse
committed
chore: Overhaul CLI tests for better ergonomics.
1 parent 8bb09e4 commit cc88afa

8 files changed

Lines changed: 1855 additions & 1433 deletions

File tree

influxdb3/src/commands/query.rs

Lines changed: 3 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@ pub(crate) enum Error {
1818
#[error(transparent)]
1919
Client(#[from] influxdb3_client::Error),
2020

21-
#[error(transparent)]
22-
Query(#[from] QueryError),
23-
2421
#[error("invlid UTF8 received from server: {0}")]
2522
Utf8(#[from] Utf8Error),
2623

@@ -42,7 +39,7 @@ pub(crate) enum Error {
4239
pub(crate) type Result<T> = std::result::Result<T, Error>;
4340

4441
#[derive(Debug, Parser)]
45-
#[clap(visible_alias = "q", trailing_var_arg = true)]
42+
#[clap(visible_alias = "q")]
4643
pub struct Config {
4744
/// Common InfluxDB 3 Core config
4845
#[clap(flatten)]
@@ -73,7 +70,7 @@ pub struct Config {
7370
file_path: Option<String>,
7471

7572
/// The query string to execute
76-
query: Option<Vec<String>>,
73+
query: Option<String>,
7774
}
7875

7976
#[derive(Debug, ValueEnum, Clone)]
@@ -94,7 +91,7 @@ pub(crate) async fn command(config: Config) -> Result<()> {
9491
}
9592

9693
let query = if let Some(query) = config.query {
97-
parse_query(query)?
94+
query
9895
} else if let Some(file_path) = config.file_path {
9996
fs::read_to_string(file_path)?
10097
} else {
@@ -145,27 +142,3 @@ pub(crate) async fn command(config: Config) -> Result<()> {
145142

146143
Ok(())
147144
}
148-
149-
#[derive(Debug, thiserror::Error)]
150-
pub(crate) enum QueryError {
151-
#[error("no query provided")]
152-
NoQuery,
153-
154-
#[error(
155-
"ensure that a single query string is provided as the final \
156-
argument, enclosed in quotes"
157-
)]
158-
MoreThanOne,
159-
}
160-
161-
/// Parse the user-inputted query string
162-
fn parse_query(mut input: Vec<String>) -> Result<String> {
163-
if input.is_empty() {
164-
Err(QueryError::NoQuery)?
165-
}
166-
if input.len() > 1 {
167-
Err(QueryError::MoreThanOne)?
168-
} else {
169-
Ok(input.remove(0))
170-
}
171-
}

influxdb3/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use trogging::{
2222
};
2323

2424
pub mod commands {
25-
pub(crate) mod common;
25+
pub mod common;
2626
pub mod create;
2727
pub mod delete;
2828
pub mod disable;

0 commit comments

Comments
 (0)