polars_ai/cli.rs
1use clap::Args;
2use clap::{Parser, Subcommand};
3
4#[derive(Parser)]
5/// The top-level command-line interface for the Polars AI CLI.
6///
7/// # Examples
8///
9/// ```
10/// // Create and configure the CLI.
11/// let cli = Cli::parse();
12///
13/// // Run the CLI.
14/// match cli.command {
15/// Some(command) => match command {
16/// // Handle subcommands here.
17/// Commands::Input(input) => {
18/// // Process input commands.
19/// }
20/// },
21/// None => {
22/// // Handle the absence of subcommands.
23/// }
24/// }
25/// ```
26#[command(name = "polars-ai")]
27#[command(author = "Mahmoud Harmouch <oss@wiseai.dev>")]
28#[command(version = "0.0.2")]
29#[command(propagate_version = true)]
30#[command(about = "\x1b[1;92m📊 Simple AI powered CLI for working with Polars DataFrames 📊\x1b[0m", long_about = None)]
31pub struct Cli {
32 /// Turn debugging information on.
33 #[arg(short, long, action = clap::ArgAction::Count)]
34 debug: u8,
35 /// The subcommand to execute.
36 #[command(subcommand)]
37 pub command: Option<Commands>,
38}
39
40/// Represents available subcommands for the CLI.
41#[derive(Subcommand, Debug)]
42pub enum Commands {
43 /// Subcommand for handling input operations.
44 Input(Input),
45}
46
47/// Represents input-related commands.
48#[derive(Debug, Args)]
49pub struct Input {
50 /// Input CSV file.
51 #[clap(short, long)]
52 pub file_name: Option<String>,
53 /// The specific input command to execute.
54 #[command(subcommand)]
55 pub command: InputCommands,
56}
57
58/// Represents subcommands for input-related operations.
59#[derive(Subcommand, Debug)]
60pub enum InputCommands {
61 /// Subcommand for showing DataFrame options.
62 Show(OptionValue),
63 /// Subcommand for asking AI-related queries.
64 Ask(Query),
65}
66
67/// Represents options for displaying DataFrames.
68#[derive(Debug, Args)]
69pub struct OptionValue {
70 /// Display the DataFrame in JSON or DataFrame format.
71 #[clap(short, long)]
72 pub option: Option<String>,
73}
74
75/// Represents a query to be asked to the AI.
76#[derive(Debug, Args)]
77pub struct Query {
78 /// The question or query to ask to the AI.
79 #[clap(short, long)]
80 pub query: Option<String>,
81}