1use clap::{Args, Parser, Subcommand, ValueEnum};
2
3#[derive(Debug, Clone, Parser)]
4#[command(name = "saya", version, about = "Database-aware AI for the terminal")]
5pub struct Cli {
6 #[command(flatten)]
7 pub options: GlobalOptions,
8 #[command(subcommand)]
9 pub command: Option<Command>,
10}
11
12#[derive(Debug, Clone, Args, Default)]
13pub struct GlobalOptions {
14 #[arg(long = "continue", global = true)]
15 pub continue_session: bool,
16 #[arg(long, global = true)]
17 pub resume: Option<String>,
18 #[arg(long, global = true)]
19 pub profile: Option<String>,
20 #[arg(long = "include-profile", global = true)]
21 pub include_profiles: Vec<String>,
22 #[arg(long, value_name = "MODE", global = true)]
23 pub approval_mode: Option<String>,
24 #[arg(long, value_enum, default_value_t = FormatArg::Text, global = true)]
25 pub format: FormatArg,
26 #[arg(long, global = true)]
27 pub non_interactive: bool,
28 #[arg(long, global = true)]
29 pub config: Option<std::path::PathBuf>,
30 #[arg(long, global = true)]
31 pub connections: Option<std::path::PathBuf>,
32 #[arg(long, global = true)]
33 pub env_file: Option<std::path::PathBuf>,
34 #[arg(long, global = true)]
35 pub allow_data_sharing: bool,
36 #[arg(long, global = true)]
37 pub no_color: bool,
38 #[arg(long, short, global = true)]
39 pub verbose: bool,
40}
41
42#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, ValueEnum)]
43pub enum FormatArg {
44 #[default]
45 Text,
46 Json,
47 Ndjson,
48}
49
50#[derive(Debug, Clone, Subcommand)]
51pub enum Command {
52 Config {
53 #[command(subcommand)]
54 command: ConfigCommand,
55 },
56 Connection {
57 #[command(subcommand)]
58 command: ConnectionCommand,
59 },
60 Ask {
61 prompt: Option<String>,
62 #[arg(long)]
63 file: Option<std::path::PathBuf>,
64 },
65 Query {
66 #[arg(long)]
67 sql: Option<String>,
68 #[arg(long)]
69 file: Option<std::path::PathBuf>,
70 },
71}
72
73#[derive(Debug, Clone, Subcommand)]
74pub enum ConfigCommand {
75 Init,
76 Doctor,
77 Show {
78 #[arg(long)]
79 resolved: bool,
80 #[arg(long)]
81 redacted: bool,
82 },
83}
84
85#[derive(Debug, Clone, Subcommand)]
86pub enum ConnectionCommand {
87 List,
88 Test {
89 #[arg(value_name = "PROFILE")]
90 profile_name: String,
91 },
92 Schema {
93 #[arg(value_name = "PROFILE")]
94 profile_name: String,
95 #[arg(long)]
96 refresh: bool,
97 },
98}