Some relevant docstrings
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
parent
92fec23932
commit
83a4138f64
|
@ -1,5 +1,6 @@
|
|||
use clap::{arg, ArgAction, Command};
|
||||
|
||||
// Generate command line options for the csv command
|
||||
pub fn gen_csv_command() -> Command {
|
||||
Command::new("csv")
|
||||
.about("Read csv, output arrow stream")
|
||||
|
@ -29,6 +30,7 @@ pub fn gen_csv_command() -> Command {
|
|||
)
|
||||
}
|
||||
|
||||
// Generate command line options for the schema command
|
||||
pub fn gen_schema_command() -> Command {
|
||||
Command::new("schema")
|
||||
.about("Several table schema related utilities")
|
||||
|
@ -52,6 +54,7 @@ pub fn gen_schema_command() -> Command {
|
|||
)
|
||||
}
|
||||
|
||||
// Generate command line options for the sql command
|
||||
pub fn gen_sql_command() -> Command {
|
||||
Command::new("sql")
|
||||
.about("Runs a sql statement on the file")
|
||||
|
@ -65,6 +68,7 @@ pub fn gen_sql_command() -> Command {
|
|||
.arg(arg!(-d --delimiter <String> "Column delimiter").required(false))
|
||||
}
|
||||
|
||||
// Generate command line options for the rpq command
|
||||
pub fn gen_rpq_command() -> Command {
|
||||
Command::new("rpq")
|
||||
.about("Read parquet file")
|
||||
|
@ -93,6 +97,7 @@ pub fn gen_rpq_command() -> Command {
|
|||
)
|
||||
}
|
||||
|
||||
// Generate command line options for the wpq command
|
||||
pub fn gen_wpq_command() -> Command {
|
||||
Command::new("wpq")
|
||||
.about("Write to a paquet file")
|
||||
|
@ -105,6 +110,7 @@ pub fn gen_wpq_command() -> Command {
|
|||
.arg(arg!([path] "Path to the new parquet file"))
|
||||
}
|
||||
|
||||
// Generate command line options for the print command
|
||||
pub fn gen_print_command() -> Command {
|
||||
Command::new("print")
|
||||
.about("Pretty prints the table")
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
use crate::io;
|
||||
use crate::sql;
|
||||
use crate::schema;
|
||||
use crate::sql;
|
||||
use clap::ArgMatches;
|
||||
use polars_lazy::prelude::LazyFrame;
|
||||
|
||||
// Handle csv command
|
||||
pub fn handle_csv(matches: &ArgMatches) {
|
||||
let delimiter = match matches.get_one::<String>("delimiter") {
|
||||
Some(delimiter) => delimiter.as_bytes()[0],
|
||||
|
@ -39,6 +40,7 @@ pub fn handle_csv(matches: &ArgMatches) {
|
|||
}
|
||||
}
|
||||
|
||||
// Handle the SQL command
|
||||
pub fn handle_sql(matches: &ArgMatches) {
|
||||
let delimiter = match matches.get_one::<String>("delimiter") {
|
||||
Some(delimiter) => delimiter.as_bytes()[0],
|
||||
|
@ -57,6 +59,7 @@ pub fn handle_sql(matches: &ArgMatches) {
|
|||
}
|
||||
}
|
||||
|
||||
// Handle the print command
|
||||
pub fn handle_print(matches: &ArgMatches) {
|
||||
let delimiter = match matches.get_one::<String>("delimiter") {
|
||||
Some(delimiter) => delimiter.as_bytes()[0],
|
||||
|
@ -70,6 +73,7 @@ pub fn handle_print(matches: &ArgMatches) {
|
|||
println!("{}", df.collect().expect("Could not collect"));
|
||||
}
|
||||
|
||||
// Handle the rpq command
|
||||
pub fn handle_rpq(matches: &ArgMatches) {
|
||||
let mut ldf = LazyFrame::default();
|
||||
if matches.get_flag("stdin") {
|
||||
|
@ -99,9 +103,9 @@ pub fn handle_rpq(matches: &ArgMatches) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Handle the wpq command
|
||||
pub fn handle_wpq(matches: &ArgMatches) {
|
||||
let delimiter = match matches.get_one::<String>("delimiter") {
|
||||
Some(delimiter) => delimiter.as_bytes()[0],
|
||||
|
@ -119,6 +123,7 @@ pub fn handle_wpq(matches: &ArgMatches) {
|
|||
}
|
||||
}
|
||||
|
||||
// Handle the schema command
|
||||
pub fn handle_schema(matches: &ArgMatches) {
|
||||
let delimiter = match matches.get_one::<String>("delimiter") {
|
||||
Some(delimiter) => delimiter.as_bytes()[0],
|
||||
|
|
|
@ -6,6 +6,7 @@ mod sql;
|
|||
use clap::command;
|
||||
|
||||
fn main() {
|
||||
// Commands definition
|
||||
let matches = command!()
|
||||
.subcommand(commands::gen_csv_command())
|
||||
.subcommand(commands::gen_schema_command())
|
||||
|
@ -14,6 +15,8 @@ fn main() {
|
|||
.subcommand(commands::gen_rpq_command())
|
||||
.subcommand(commands::gen_wpq_command())
|
||||
.get_matches();
|
||||
|
||||
// Send the flow to the corresponding handler
|
||||
if let Some(sub_matches) = matches.subcommand_matches("csv") {
|
||||
handlers::handle_csv(sub_matches);
|
||||
} else if let Some(sub_matches) = matches.subcommand_matches("sql") {
|
||||
|
|
Loading…
Reference in a new issue