use clap::{Args, Parser, Subcommand};
use std::path::PathBuf;
#[derive(Parser, Debug)]
#[command(author, version, about, long_about = None)]
#[command(propagate_version = true)]
pub struct Cli {
#[command(subcommand)]
pub command: Commands,
#[arg(long, global = true)]
pub workspace: Option<PathBuf>,
#[arg(short, long, action = clap::ArgAction::Count, global = true)]
pub verbose: u8,
#[arg(short, long, global = true)]
pub quiet: bool,
}
#[derive(Subcommand, Debug)]
pub enum Commands {
Import(ImportArgs),
Chat(ChatArgs),
Show(ShowArgs),
Open(OpenArgs),
Search(SearchArgs),
Install(InstallArgs),
Config(ConfigArgs),
Workspace(WorkspaceArgs),
}
#[derive(Args, Debug)]
pub struct ImportArgs {
#[arg(required = true)]
pub paths: Vec<PathBuf>,
#[arg(long, value_parser = clap::value_parser!(String))] pub metadata: Vec<String>,
#[arg(long, short)]
pub tags: Vec<String>,
#[arg(long)]
pub model: Option<String>,
}
#[derive(Args, Debug)]
pub struct ChatArgs {
#[arg(required = false)]
pub docs: Vec<String>,
#[arg(long, short)]
pub prompt: Option<String>,
#[arg(long)]
pub scope: Vec<String>,
#[arg(long, short)]
pub model: Option<String>,
#[arg(long)]
pub plugins: Vec<String>,
}
#[derive(Args, Debug)]
pub struct ShowArgs {
pub document: Option<String>,
#[arg(long, short)]
pub metadata: bool,
#[arg(long, short)]
pub embeddings: bool,
}
#[derive(Args, Debug)]
pub struct OpenArgs {
#[arg(required = true)]
pub document_id: String,
}
#[derive(Args, Debug)]
pub struct SearchArgs {
#[arg(required = true)]
pub query: String,
#[arg(long, short)]
pub model: Option<String>,
#[arg(long)]
pub scope: Vec<String>,
#[arg(long, short, default_value = "10")]
pub limit: usize,
}
#[derive(Args, Debug)]
pub struct InstallArgs {
#[arg(long, conflicts_with = "url")]
pub path: Option<PathBuf>,
#[arg(long, conflicts_with = "path")]
pub url: Option<String>,
}
#[derive(Args, Debug)]
pub struct ConfigArgs {
#[command(subcommand)]
pub command: ConfigCommands,
}
#[derive(Subcommand, Debug)]
pub enum ConfigCommands {
Get {
key: String,
#[arg(long)]
global: bool,
},
Set {
key: String,
value: String,
#[arg(long)]
global: bool,
},
List {
#[arg(long)]
global: bool,
},
Locate {},
}
#[derive(Args, Debug)]
pub struct WorkspaceArgs {
#[command(subcommand)]
pub command: WorkspaceCommands,
}
#[derive(Subcommand, Debug)]
pub enum WorkspaceCommands {
Create {
path: Option<PathBuf>,
#[arg(long, short)]
name: Option<String>,
},
List {},
Delete {
target: String, #[arg(long, short)]
force: bool, },
Info { target: Option<String>,
}
}