1use crate::action;
2use clap::{Parser, Subcommand};
3
4#[derive(Debug, Parser)]
5#[command(name = "quartz")]
6#[command(author = "Eduardo R. <contato@edurodrigues.dev>")]
7#[command(about = "Text-based API Client", long_about = None, version)]
8pub struct Cli {
9 #[arg(short = 'x', value_name = "HANDLE")]
11 pub from_handle: Option<String>,
12
13 #[arg(short = 'c', long)]
16 pub apply_environment: bool,
17
18 #[command(subcommand)]
19 pub command: Cmd,
20}
21
22#[derive(Debug, Subcommand)]
23pub enum Cmd {
24 Init(action::init::Args),
26 Send(action::send::Args),
28 Create(action::handle::CreateArgs),
30 Use(action::handle::SwitchArgs),
32
33 #[command(name = "ls", alias = "list")]
35 Ls(action::ls::Args),
36
37 #[command(name = "cp", alias = "copy")]
39 Cp(action::handle::CpArgs),
40
41 #[command(name = "mv", alias = "move")]
43 Mv(action::handle::MvArgs),
44
45 #[command(name = "rm", alias = "remove")]
47 Rm(action::handle::RmArgs),
48
49 Show {
51 #[command(subcommand)]
52 command: ShowCmd,
53 },
54
55 Edit,
57
58 Query {
60 #[command(subcommand)]
61 command: QueryCmd,
62 },
63 #[command(alias = "headers")]
65 Header {
66 #[command(subcommand)]
67 command: HeaderCmd,
68 },
69 Body(action::body::Args),
71 Last {
73 #[command(subcommand)]
74 command: Option<LastCmd>,
75 },
76 History(action::history::Args),
78 #[command(name = "env", alias = "environment")]
80 Env {
81 #[command(subcommand)]
82 command: EnvCmd,
83 },
84 #[command(name = "var", alias = "variable")]
86 Var {
87 #[command(subcommand)]
88 command: VarCmd,
89 },
90 Config {
92 #[command(subcommand)]
93 command: ConfigCmd,
94 },
95}
96
97#[derive(Debug, Subcommand)]
98pub enum LastCmd {
99 Handle,
101
102 #[command(name = "req", alias = "request")]
104 Req,
105 #[command(name = "res", alias = "response")]
107 Res {
108 #[command(subcommand)]
109 command: Option<LastResCmd>,
110 },
111}
112
113#[derive(Debug, Subcommand)]
114pub enum LastResCmd {
115 Head,
116 Body,
117}
118
119#[derive(Debug, Subcommand)]
120pub enum QueryCmd {
121 Get(action::query::GetArgs),
123
124 Set(action::query::SetArgs),
126
127 #[command(name = "rm", alias = "remove")]
129 Rm(action::query::RmArgs),
130
131 #[command(name = "ls", alias = "list")]
133 Ls,
134}
135
136#[derive(Debug, Subcommand)]
137pub enum HeaderCmd {
138 Get { key: String },
140
141 Set { header: Vec<String> },
143
144 #[command(name = "rm", alias = "remove")]
146 Rm { key: Vec<String> },
147
148 #[command(name = "ls", alias = "list")]
150 Ls,
151}
152
153#[derive(Debug, Subcommand)]
154pub enum ShowCmd {
155 Url,
156 Method,
157 Headers {
159 key: Option<String>,
160 },
161 Query {
163 key: Option<String>,
164 },
165 Body,
167 Handle,
169 #[command(name = "env", alias = "environment")]
171 Env,
172
173 Cookies(action::cookie::PrintArgs),
175 Snippet(action::snippet::Args),
177 Endpoint,
179}
180
181#[derive(Debug, Subcommand)]
182pub enum SnippetCmd {
183 Curl(crate::snippet::Curl),
184 Http,
185}
186
187#[derive(Debug, Subcommand)]
188pub enum ConfigCmd {
189 Edit,
191
192 Get(action::config::GetArgs),
194
195 Set(action::config::SetArgs),
197
198 #[command(name = "ls", alias = "list")]
200 Ls,
201}
202
203#[derive(Debug, Subcommand)]
204pub enum BodyCmd {
205 Show,
207
208 Stdin,
210
211 Edit,
213}
214
215#[derive(Debug, Subcommand)]
216pub enum EnvCmd {
217 Create(action::env::CreateArgs),
219
220 Use(action::env::SwitchArgs),
222
223 #[command(name = "ls", alias = "list")]
225 Ls,
226
227 #[command(name = "cp", alias = "copy")]
229 Cp(action::env::CpArgs),
230
231 #[command(name = "rm", alias = "remove")]
233 Rm(action::env::RmArgs),
234 Header {
235 #[command(subcommand)]
236 command: HeaderCmd,
237 },
238}
239
240#[derive(Debug, Subcommand)]
241pub enum VarCmd {
242 Edit,
244
245 Get(action::var::GetArgs),
247
248 Set(action::var::SetArgs),
250
251 Rm(action::var::RmArgs),
253
254 #[command(name = "ls", alias = "list")]
256 Ls,
257}