Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
474 changes: 458 additions & 16 deletions Cargo.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ reqwest = { version = "0.12", features = ["blocking", "json"] }
rayon = "1.10"
serde = { version = "1", features = ["derive"] }
serde_json = "1"
arrow = { version = "54", default-features = false, features = ["ipc"] }
serde_yaml = "0.9"
base64 = "0.22"
crossterm = "0.28"
Expand Down
14 changes: 14 additions & 0 deletions src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,20 @@ impl ApiClient {
self.send(req, None)
}

/// GET with a custom Accept header; returns raw bytes instead of decoded text.
/// Used for binary result formats such as Arrow IPC streams.
pub fn get_bytes(&self, path: &str, accept: &str) -> (reqwest::StatusCode, Vec<u8>) {
let url = format!("{}{path}", self.api_url);
let req = self.build_request(reqwest::Method::GET, &url).header("Accept", accept);
match util::send_debug_bytes(&self.client, req) {
Ok(pair) => pair,
Err(e) => {
eprintln!("error connecting to API: {e}");
std::process::exit(1);
}
}
}
Comment thread
eddietejeda marked this conversation as resolved.

/// POST request with JSON body, exits on error, returns raw (status, body).
pub fn post_raw(&self, path: &str, body: &serde_json::Value) -> (reqwest::StatusCode, String) {
let url = format!("{}{path}", self.api_url);
Expand Down
17 changes: 16 additions & 1 deletion src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,16 @@ pub enum DatabasesCommands {
output: String,
},

/// Show details for a specific managed database
Show {
/// Database name or ID
name_or_id: String,

/// Output format
#[arg(long = "output", short = 'o', default_value = "table", value_parser = ["table", "json", "yaml"])]
output: String,
},

/// Create a new managed database
Create {
/// Optional display label (not unique, not an identifier — databases are addressed by id)
Expand Down Expand Up @@ -604,8 +614,11 @@ pub enum DatabasesCommands {

/// Manage tables inside a managed database
Tables {
/// Database id or description — shorthand for `tables list` when no subcommand is given
database: Option<String>,

#[command(subcommand)]
command: DatabaseTablesCommands,
command: Option<DatabaseTablesCommands>,
},
}

Expand Down Expand Up @@ -738,6 +751,8 @@ pub enum SkillCommands {
},
/// Show the installation status of the hotdata skill
Status,
/// List installed skills and their versions (alias for status)
List,
}

#[derive(Subcommand)]
Expand Down
51 changes: 37 additions & 14 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,9 @@ fn main() {
Some(DatabasesCommands::List { output }) => {
databases::list(&workspace_id, &output)
}
Some(DatabasesCommands::Show { name_or_id, output }) => {
databases::get(&workspace_id, &name_or_id, &output)
}
Some(DatabasesCommands::Create {
description,
schema,
Expand Down Expand Up @@ -427,43 +430,63 @@ fn main() {
upload_id.as_deref(),
)
}
Some(DatabasesCommands::Tables { command }) => match command {
DatabaseTablesCommands::List {
database,
Some(DatabasesCommands::Tables { database, command }) => match command {
Some(DatabaseTablesCommands::List {
database: db_flag,
schema,
output,
} => databases::tables_list(
}) => databases::tables_list(
&workspace_id,
database.as_deref(),
db_flag.as_deref().or(database.as_deref()),
schema.as_deref(),
&output,
),
DatabaseTablesCommands::Load {
database,
Some(DatabaseTablesCommands::Load {
database: db_flag,
table,
schema,
file,
url,
upload_id,
} => databases::tables_load(
}) => databases::tables_load(
&workspace_id,
database.as_deref(),
db_flag.as_deref().or(database.as_deref()),
&table,
Some(schema.as_str()),
file.as_deref(),
url.as_deref(),
upload_id.as_deref(),
),
DatabaseTablesCommands::Delete {
database,
Some(DatabaseTablesCommands::Delete {
database: db_flag,
table,
schema,
} => databases::tables_delete(
}) => databases::tables_delete(
&workspace_id,
database.as_deref(),
db_flag.as_deref().or(database.as_deref()),
&table,
Some(schema.as_str()),
),
None => {
if let Some(ref db) = database {
databases::tables_list(
&workspace_id,
Some(db.as_str()),
None,
"table",
)
} else {
use clap::CommandFactory;
let mut cmd = Cli::command();
cmd.build();
cmd.find_subcommand_mut("databases")
.unwrap()
.find_subcommand_mut("tables")
.unwrap()
.print_help()
.unwrap();
}
}
},
None => {
use clap::CommandFactory;
Expand Down Expand Up @@ -507,7 +530,7 @@ fn main() {
skill::install()
}
}
SkillCommands::Status => skill::status(),
SkillCommands::Status | SkillCommands::List => skill::status(),
},
Commands::Results {
result_id,
Expand Down
Loading
Loading