1use clap::{Args, Subcommand};
2
3use crate::render::{CommandOutput, CommandResult};
4
5#[derive(Subcommand, Clone, Debug)]
6pub enum TemplateCommands {
7 #[command(name = "item")]
8 Item,
9 #[command(name = "item.field")]
10 ItemField,
11 #[command(name = "item.login")]
12 ItemLogin,
13 #[command(name = "item.login.uri")]
14 ItemLoginUri,
15 #[command(name = "item.card")]
16 ItemCard,
17 #[command(name = "item.identity")]
18 ItemIdentity,
19 #[command(name = "item.securenote")]
20 ItemSecureNote,
21 #[command(name = "folder")]
22 Folder,
23 #[command(name = "collection")]
24 Collection,
25 #[command(name = "item-collections")]
26 ItemCollections,
27 #[command(name = "org-collection")]
28 OrgCollection,
29 #[command(name = "send.text")]
30 SendText,
31 #[command(name = "send.file")]
32 SendFile,
33}
34
35impl TemplateCommands {
36 pub fn run(&self) -> CommandResult {
37 match self {
38 Self::Folder => {
39 #[derive(serde::Serialize)]
40 struct FolderTemplate {
41 name: String,
42 }
43
44 Ok(CommandOutput::Object(Box::new(FolderTemplate {
45 name: "Folder name".to_string(),
46 })))
47 }
48 _ => todo!(),
49 }
50 }
51}
52
53#[derive(Args, Clone)]
54pub struct ListItemsArgs {
55 #[arg(long, help = "Filter items by URL")]
56 pub url: Option<String>,
57
58 #[arg(long, alias = "folderid", help = "Filter items by folder ID")]
59 pub folder_id: Option<String>,
60
61 #[arg(long, alias = "collectionid", help = "Filter items by collection ID")]
62 pub collection_id: Option<String>,
63
64 #[arg(
65 long,
66 alias = "organizationid",
67 help = "Filter items by organization ID"
68 )]
69 pub organization_id: Option<String>,
70
71 #[arg(long, help = "Filter items in trash")]
72 pub trash: bool,
73
74 #[arg(long, help = "Search term")]
75 pub search: Option<String>,
76}
77
78#[derive(Args, Clone)]
79pub struct ListFoldersArgs {
80 #[arg(long, help = "Search term")]
81 pub search: Option<String>,
82}
83
84#[derive(Args, Clone)]
85pub struct DeleteItemArgs {
86 pub id: String,
87 #[arg(short = 'p', long, help = "Permanently delete the item (skip trash)")]
88 pub permanent: bool,
89}
90
91#[derive(Args, Clone)]
92pub struct DeleteAttachmentArgs {
93 pub id: String,
94 #[arg(
95 long,
96 alias = "itemid",
97 help = "Item ID that the attachment belongs to"
98 )]
99 pub item_id: String,
100}
101
102#[derive(Args, Clone)]
103pub struct DeleteFolderArgs {
104 pub id: String,
105 #[arg(short = 'p', long, help = "Permanently delete the folder (skip trash)")]
106 pub permanent: bool,
107}
108
109#[derive(Args, Clone)]
110pub struct EditItemArgs {
111 pub id: String,
113 pub encoded_json: Option<String>,
115}
116
117#[derive(Args, Clone)]
118pub struct EditItemCollectionsArgs {
119 pub id: String,
121 pub encoded_json: Option<String>,
123}
124
125#[derive(Args, Clone)]
126pub struct EditFolderArgs {
127 pub id: String,
129 pub encoded_json: Option<String>,
131}
132
133#[derive(Args, Clone)]
134pub struct GetItemArgs {
135 pub id: String,
136}
137
138#[derive(Args, Clone)]
139pub struct GetUsernameArgs {
140 pub id: String,
141}
142
143#[derive(Args, Clone)]
144pub struct GetPasswordArgs {
145 pub id: String,
146}
147
148#[derive(Args, Clone)]
149pub struct GetUriArgs {
150 pub id: String,
151}
152
153#[derive(Args, Clone)]
154pub struct GetTotpArgs {
155 pub id: String,
156}
157
158#[derive(Args, Clone)]
159pub struct GetNotesArgs {
160 pub id: String,
161}
162
163#[derive(Args, Clone)]
164pub struct GetFolderArgs {
165 pub id: String,
166}
167
168#[derive(Args, Clone)]
169pub struct GetAttachmentArgs {
170 pub filename: String,
171 #[arg(
172 long,
173 alias = "itemid",
174 help = "Item ID that the attachment belongs to."
175 )]
176 pub item_id: String,
177 #[arg(long, help = "Output file path. If not specified, outputs to stdout.")]
178 pub output: Option<String>,
179}
180
181#[derive(clap::Args, Clone)]
182pub struct RestoreArgs {
183 pub object: RestoreObject,
185 pub id: String,
187}
188
189#[derive(clap::ValueEnum, Clone, Debug)]
190#[value(rename_all = "kebab-case")]
191pub enum RestoreObject {
192 Item,
193}
194
195#[derive(clap::Args, Clone)]
196pub struct CreateItemArgs {
197 #[arg(help = "Base64-encoded JSON item object")]
198 encoded_json: String,
199}
200
201#[derive(clap::Args, Clone)]
202pub struct CreateAttachmentArgs {
203 #[arg(long, help = "Path to the file to attach")]
204 file: String,
205 #[arg(long, alias = "itemid", help = "Item ID to attach the file to")]
206 item_id: String,
207}
208
209#[derive(clap::Args, Clone)]
210pub struct CreateFolderArgs {
211 #[arg(help = "Base64-encoded JSON folder object")]
212 encoded_json: String,
213}