bw/vault/
mod.rs

1use clap::Subcommand;
2
3use crate::render::{CommandOutput, CommandResult};
4
5mod sync;
6
7pub(crate) use sync::{SyncRequest, sync};
8
9#[derive(Subcommand, Clone, Debug)]
10pub enum TemplateCommands {
11    #[command(name = "item")]
12    Item,
13    #[command(name = "item.field")]
14    ItemField,
15    #[command(name = "item.login")]
16    ItemLogin,
17    #[command(name = "item.login.uri")]
18    ItemLoginUri,
19    #[command(name = "item.card")]
20    ItemCard,
21    #[command(name = "item.identity")]
22    ItemIdentity,
23    #[command(name = "item.securenote")]
24    ItemSecureNote,
25    #[command(name = "folder")]
26    Folder,
27    #[command(name = "collection")]
28    Collection,
29    #[command(name = "item-collections")]
30    ItemCollections,
31    #[command(name = "org-collection")]
32    OrgCollection,
33    #[command(name = "send.text")]
34    SendText,
35    #[command(name = "send.file")]
36    SendFile,
37}
38
39impl TemplateCommands {
40    pub fn run(&self) -> CommandResult {
41        match self {
42            Self::Folder => {
43                #[derive(serde::Serialize)]
44                struct FolderTemplate {
45                    name: String,
46                }
47
48                Ok(CommandOutput::Object(Box::new(FolderTemplate {
49                    name: "Folder name".to_string(),
50                })))
51            }
52            _ => todo!(),
53        }
54    }
55}
56
57#[derive(clap::Args, Clone)]
58pub struct RestoreArgs {
59    /// Type of object to restore
60    pub object: RestoreObject,
61    /// Object ID to restore
62    pub id: String,
63}
64
65#[derive(clap::ValueEnum, Clone, Debug)]
66#[value(rename_all = "kebab-case")]
67pub enum RestoreObject {
68    Item,
69}