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,
124
125 #[arg(short = 'r', long, value_parser = parse_duration, default_value = "60m")]
127 pub reuse_time: Duration,
128}
129
130#[derive(Args, Clone)]
131pub struct DatabaseArgs {
132 #[command(flatten)]
134 pub aws: AwsArgs,
135}
136
137#[derive(Args, Clone)]
138pub struct TableArgs {
139 #[arg(short = 'n', long)]
141 pub db: Option<String>,
142
143 #[arg(short, long)]
145 pub filter: Option<String>,
146
147 #[arg(short, long, default_value = "50")]
149 pub limit: i32,
150}
151
152#[derive(Args, Clone)]
153pub struct DescribeTableArgs {
154 pub table: String,
156
157 #[arg(short = 'n', long)]
159 pub db: Option<String>,
160}
161
162#[derive(Args, Clone)]
163pub struct WorkgroupArgs {
164 #[arg(short, long, default_value = "50")]
166 pub limit: i32,
167}
168
169#[derive(Args, Clone)]
170pub struct HistoryArgs {
171 #[arg(short, long)]
173 pub limit: Option<i32>,
174
175 #[arg(short, long)]
177 pub status: Option<String>,
178}
179
180#[derive(Args, Clone)]
182pub struct InspectArgs {
183 pub query_id: String,
185
186 #[arg(short, long)]
188 pub output: Option<String>,
189
190 #[arg(short, long)]
192 pub quiet: bool,
193}
194
195#[derive(Args, Clone)]
196pub struct DownloadArgs {
197 pub query_id: String,
199
200 #[arg(short, long, default_value = ".")]
202 pub output: Option<String>,
203}