Skip to main content

bw/command/
get.rs

1use clap::Subcommand;
2
3use crate::{
4    admin_console::{GetCollectionArgs, GetOrgCollectionArgs, GetOrganizationArgs},
5    dirt::GetExposedArgs,
6    platform::GetFingerprintArgs,
7    render::CommandOutput,
8    tools::GetSendArgs,
9    vault::{
10        GetAttachmentArgs, GetFolderArgs, GetItemArgs, GetNotesArgs, GetPasswordArgs, GetTotpArgs,
11        GetUriArgs, GetUsernameArgs, TemplateCommands,
12    },
13};
14
15#[derive(Subcommand, Clone)]
16pub enum GetCommands {
17    #[command(about = "Get an item from the vault.")]
18    Item(GetItemArgs),
19
20    #[command(about = "Get the username for an item.")]
21    Username(GetUsernameArgs),
22
23    #[command(about = "Get the password for an item.")]
24    Password(GetPasswordArgs),
25
26    #[command(about = "Get the URI for an item.")]
27    Uri(GetUriArgs),
28
29    #[command(about = "Get the TOTP code for an item.")]
30    Totp(GetTotpArgs),
31
32    #[command(about = "Check if an item password has been exposed in a data breach.")]
33    Exposed(GetExposedArgs),
34
35    #[command(about = "Get the notes for an item.")]
36    Notes(GetNotesArgs),
37
38    #[command(about = "Get a folder from the vault.")]
39    Folder(GetFolderArgs),
40
41    #[command(about = "Get a collection from the vault.")]
42    Collection(GetCollectionArgs),
43
44    #[command(about = "Get an organization.")]
45    Organization(GetOrganizationArgs),
46
47    #[command(about = "Get an organization collection.")]
48    OrgCollection(GetOrgCollectionArgs),
49
50    #[command(about = "Get an attachment from an item.")]
51    Attachment(GetAttachmentArgs),
52
53    #[command(about = "Get the fingerprint for the current user or a specified user.")]
54    Fingerprint(GetFingerprintArgs),
55
56    #[command(about = "Get a JSON template for creating objects.")]
57    Template {
58        #[command(subcommand)]
59        command: TemplateCommands,
60    },
61
62    #[command(about = "Get a Bitwarden Send.")]
63    Send(GetSendArgs),
64}
65
66/// Get command is unowned as it spans multiple teams.
67///
68/// Sub-commands should delegate to team owned implementations.
69impl GetCommands {
70    pub fn run(&self) -> color_eyre::eyre::Result<CommandOutput> {
71        match self {
72            GetCommands::Template { command } => command.run(),
73            _ => todo!(),
74        }
75    }
76}