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

flesh out native query cli interface #129

25 changes: 25 additions & 0 deletions Cargo.lock

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

5 changes: 3 additions & 2 deletions crates/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ edition = "2021"
version.workspace = true

[features]
native-query-subcommand = []
native-query-subcommand = ["dep:pretty", "dep:nom"]

[dependencies]
configuration = { path = "../configuration" }
Expand All @@ -19,8 +19,9 @@ futures-util = "0.3.28"
indexmap = { workspace = true }
itertools = { workspace = true }
ndc-models = { workspace = true }
nom = "^7.1.3"
nom = { version = "^7.1.3", optional = true }
nonempty = "^0.10.0"
pretty = { version = "^0.12.3", features = ["termcolor"], optional = true }
ref-cast = { workspace = true }
regex = "^1.11.1"
serde = { workspace = true }
Expand Down
4 changes: 4 additions & 0 deletions crates/cli/src/exit_codes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ pub enum ExitCode {
CouldNotReadConfiguration,
CouldNotProcessAggregationPipeline,
ErrorWriting,
InvalidArguments,
RefusedToOverwrite,
ResourceNotFound,
}

impl From<ExitCode> for i32 {
Expand All @@ -14,7 +16,9 @@ impl From<ExitCode> for i32 {
ExitCode::CouldNotReadConfiguration => 202,
ExitCode::CouldNotProcessAggregationPipeline => 205,
ExitCode::ErrorWriting => 204,
ExitCode::InvalidArguments => 400,
ExitCode::RefusedToOverwrite => 203,
ExitCode::ResourceNotFound => 404,
}
}
}
1 change: 1 addition & 0 deletions crates/cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ pub enum Command {
pub struct Context {
pub path: PathBuf,
pub connection_uri: Option<String>,
pub display_color: bool,
}

/// Run a command in a given directory.
Expand Down
5 changes: 5 additions & 0 deletions crates/cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ pub struct Args {
)]
pub connection_uri: Option<String>,

/// Disable color in command output.
#[arg(long = "no-color", short = 'C')]
pub no_color: bool,

/// The command to invoke.
#[command(subcommand)]
pub subcommand: Command,
Expand All @@ -49,6 +53,7 @@ pub async fn main() -> anyhow::Result<()> {
let context = Context {
path,
connection_uri: args.connection_uri,
display_color: !args.no_color,
};
run(args.subcommand, &context).await?;
Ok(())
Expand Down
4 changes: 2 additions & 2 deletions crates/cli/src/native_query/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,10 @@ pub enum Error {
#[error("Type inference is not currently implemented for the aggregation expression operator, {0}. Please file a bug report, and declare types for your native query by hand for the time being.")]
UnknownAggregationOperator(String),

#[error("Type inference is not currently implemented for {stage}, stage number {} in your aggregation pipeline. Please file a bug report, and declare types for your native query by hand for the time being.", stage_index + 1)]
#[error("Type inference is not currently implemented for{} stage number {} in your aggregation pipeline. Please file a bug report, and declare types for your native query by hand for the time being.", match stage_name { Some(name) => format!(" {name},"), None => "".to_string() }, stage_index + 1)]
UnknownAggregationStage {
stage_index: usize,
stage: bson::Document,
stage_name: Option<&'static str>,
},

#[error("Native query input collection, \"{0}\", is not defined in the connector schema")]
Expand Down
Loading
Loading