1use clap::{Args, Parser, Subcommand};
2use humantime::parse_duration;
3use std::time::Duration;
4
5#[derive(Args, Clone, Default)]
7pub struct AwsArgs {
8 #[arg(short, long, global = true)]
10 pub profile: Option<String>,
11
12 #[arg(short, long, global = true)]
14 pub workgroup: Option<String>,
15
16 #[arg(short, long, global = true)]
18 pub database: Option<String>,
19
20 #[arg(long, global = true)]
22 pub catalog: Option<String>,
23
24 #[arg(long, global = true)]
26 pub region: Option<String>,
27
28 #[arg(long, global = true)]
30 pub output_location: Option<String>,
31}
32
33#[derive(Args, Clone, Default)]
35pub struct DisplayArgs {
36 #[arg(short, long, global = true)]
38 pub quiet: bool,
39}
40
41#[derive(Args, Clone)]
43pub struct OutputArgs {
44 #[arg(short, long)]
46 pub output: Option<String>,
47}
48
49#[derive(Parser)]
50#[command(author, version, about, long_about = None)]
51pub struct Cli {
52 #[command(subcommand)]
53 pub command: Commands,
54
55 #[command(flatten)]
56 pub aws: AwsArgs,
57
58 #[command(flatten)]
59 pub display: DisplayArgs,
60}
61
62#[derive(Subcommand)]
63pub enum Commands {
64 Query(QueryArgs),
66
67 Database {
69 #[command(subcommand)]
70 command: DatabaseCommands,
71 },
72
73 Table {
75 #[command(subcommand)]
76 command: TableCommands,
77 },
78
79 Workgroup {
81 #[command(subcommand)]
82 command: WorkgroupCommands,
83 },
84
85 History(HistoryArgs),
87
88 Inspect(InspectArgs),
90
91 #[command(alias = "dl")] Download(DownloadArgs),
94}
95
96#[derive(Subcommand)]
97pub enum DatabaseCommands {
98 List(DatabaseArgs),
100}
101
102#[derive(Subcommand)]
103pub enum TableCommands {
104 List(TableArgs),
106
107 Describe(DescribeTableArgs),
109}
110
111#[derive(Subcommand)]
112pub enum WorkgroupCommands {
113 List(WorkgroupArgs),
115}
116
117#[derive(Args, Clone)]
118pub struct QueryArgs {
119 #[command(flatten)]
120 pub aws: AwsArgs,
121
122 pub query: String,
126
127 #[arg(short = 'r', long, value_parser = parse_duration, default_value = "60m")]
132 pub reuse_time: Duration,
133}
134
135#[derive(Args, Clone)]
136pub struct DatabaseArgs {
137 #[command(flatten)]
139 pub aws: AwsArgs,
140}
141
142#[derive(Args, Clone)]
143pub struct TableArgs {
144 #[arg(short = 'n', long)]
146 pub db: Option<String>,
147
148 #[arg(short, long)]
150 pub filter: Option<String>,
151
152 #[arg(short, long, default_value = "50")]
154 pub limit: i32,
155}
156
157#[derive(Args, Clone)]
158pub struct DescribeTableArgs {
159 pub table: String,
161
162 #[arg(short = 'n', long)]
164 pub db: Option<String>,
165}
166
167#[derive(Args, Clone)]
168pub struct WorkgroupArgs {
169 #[arg(short, long, default_value = "50")]
171 pub limit: i32,
172}
173
174#[derive(Args, Clone)]
175pub struct HistoryArgs {
176 #[arg(short, long)]
178 pub limit: Option<i32>,
179
180 #[arg(short, long)]
182 pub status: Option<String>,
183}
184
185#[derive(Args, Clone)]
187pub struct InspectArgs {
188 pub query_id: String,
190
191 #[arg(short, long)]
193 pub output: Option<String>,
194
195 #[arg(short, long)]
197 pub quiet: bool,
198}
199
200#[derive(Args, Clone)]
201pub struct DownloadArgs {
202 pub query_id: String,
204
205 #[arg(short, long, default_value = ".")]
207 pub output: Option<String>,
208}