use clap::{Parser, Subcommand, ValueEnum};
pub mod commands;
#[derive(Parser)]
#[clap(
name = "ada",
about = "A tool for interrogating your documents with a large language model."
)]
pub struct Cli {
#[clap(subcommand)]
pub command: Commands,
}
#[derive(Subcommand)]
pub enum Commands {
Create {
workspace_name: String,
},
List {},
Delete {
#[clap(required_unless_present = "all")]
workspace_name: Option<String>,
#[clap(long)]
all: bool,
},
Import {
#[clap(value_enum, long)]
source: SourceType,
source_name: String,
},
Chat {
workspace_name: String,
},
Query {
workspace_name: String,
},
Zotero {
#[clap(subcommand)]
command: ZoteroCmd,
},
Config {},
}
#[derive(Subcommand)]
pub enum ZoteroCmd {
ListCollections,
Enhance {
collection_name: String,
},
}
#[derive(Clone, Debug, ValueEnum)]
pub enum SourceType {
Zotero,
Folder,
Item,
}
fn display_table(column_titles: Vec<&str>, data: Vec<Vec<String>>) {
let header_style = console::Style::new().bold();
let data_style = console::Style::new();
let mut column_widths = [0, 0, 0];
for row in data.iter() {
for (i, cell) in row.iter().enumerate() {
if cell.len() > column_widths[i] {
column_widths[i] = cell.len();
}
}
}
println!();
for (i, column_title) in column_titles.iter().enumerate() {
let padded_header = format!("{:<width$}", column_title, width = column_widths[i]);
print!("{} ", header_style.apply_to(padded_header));
}
println!();
for row in data.iter() {
for (i, cell) in row.iter().enumerate() {
let padded_cell = format!("{:<width$}", cell, width = column_widths[i]);
print!("{} ", data_style.apply_to(padded_cell));
}
println!();
}
}