feat(cli/org): org add parity for Card/Key/Totp via shared builders
This commit is contained in:
@@ -566,13 +566,15 @@ pub(crate) enum OrgAddKind {
|
||||
#[arg(long)] url: Option<String>,
|
||||
#[arg(long)] password: Option<String>,
|
||||
#[arg(long, value_delimiter = ',')] tags: Vec<String>,
|
||||
#[arg(long)] password_stdin: bool,
|
||||
},
|
||||
/// A secure note.
|
||||
SecureNote {
|
||||
#[arg(long)] collection: String,
|
||||
#[arg(long)] title: String,
|
||||
#[arg(long)] body: String,
|
||||
#[arg(long)] body: Option<String>,
|
||||
#[arg(long, value_delimiter = ',')] tags: Vec<String>,
|
||||
#[arg(long)] body_stdin: bool,
|
||||
},
|
||||
/// An identity record.
|
||||
Identity {
|
||||
@@ -583,6 +585,41 @@ pub(crate) enum OrgAddKind {
|
||||
#[arg(long)] phone: Option<String>,
|
||||
#[arg(long, value_delimiter = ',')] tags: Vec<String>,
|
||||
},
|
||||
/// A payment card (number / cvv / pin entered via --*-stdin or prompt).
|
||||
Card {
|
||||
#[arg(long)] collection: String,
|
||||
#[arg(long)] title: String,
|
||||
#[arg(long)] holder: Option<String>,
|
||||
#[arg(long)] expiry: Option<String>,
|
||||
#[arg(long, default_value = "credit")] kind: String,
|
||||
#[arg(long, value_delimiter = ',')] tags: Vec<String>,
|
||||
#[arg(long)] number_stdin: bool,
|
||||
#[arg(long)] cvv_stdin: bool,
|
||||
#[arg(long)] pin_stdin: bool,
|
||||
},
|
||||
/// A key / credential blob (material entered via --material-stdin or prompt).
|
||||
Key {
|
||||
#[arg(long)] collection: String,
|
||||
#[arg(long)] title: String,
|
||||
#[arg(long)] label: Option<String>,
|
||||
#[arg(long)] algorithm: Option<String>,
|
||||
#[arg(long)] public_key: Option<String>,
|
||||
#[arg(long, value_delimiter = ',')] tags: Vec<String>,
|
||||
#[arg(long)] material_stdin: bool,
|
||||
},
|
||||
/// A TOTP authenticator (base32 secret via --secret or --secret-stdin).
|
||||
Totp {
|
||||
#[arg(long)] collection: String,
|
||||
#[arg(long)] title: String,
|
||||
#[arg(long)] issuer: Option<String>,
|
||||
#[arg(long)] label: Option<String>,
|
||||
#[arg(long)] secret: Option<String>,
|
||||
#[arg(long, default_value_t = 30)] period: u32,
|
||||
#[arg(long, default_value_t = 6)] digits: u8,
|
||||
#[arg(long, default_value = "sha1")] algorithm: String,
|
||||
#[arg(long, value_delimiter = ',')] tags: Vec<String>,
|
||||
#[arg(long)] secret_stdin: bool,
|
||||
},
|
||||
}
|
||||
|
||||
fn main() -> Result<()> {
|
||||
@@ -676,14 +713,14 @@ fn main() -> Result<()> {
|
||||
OrgCommands::Add { kind } => {
|
||||
let d = crate::org_session::org_dir(dir_path)?;
|
||||
let (collection, add_kind, tags) = match kind {
|
||||
OrgAddKind::Login { collection, title, username, url, password, tags } => (
|
||||
OrgAddKind::Login { collection, title, username, url, password, tags, password_stdin } => (
|
||||
collection,
|
||||
commands::org::OrgAddKind::Login { title, username, url, password },
|
||||
commands::org::OrgAddKind::Login { title, username, url, password, password_stdin },
|
||||
tags,
|
||||
),
|
||||
OrgAddKind::SecureNote { collection, title, body, tags } => (
|
||||
OrgAddKind::SecureNote { collection, title, body, tags, body_stdin } => (
|
||||
collection,
|
||||
commands::org::OrgAddKind::SecureNote { title, body },
|
||||
commands::org::OrgAddKind::SecureNote { title, body, body_stdin },
|
||||
tags,
|
||||
),
|
||||
OrgAddKind::Identity { collection, title, full_name, email, phone, tags } => (
|
||||
@@ -691,6 +728,21 @@ fn main() -> Result<()> {
|
||||
commands::org::OrgAddKind::Identity { title, full_name, email, phone },
|
||||
tags,
|
||||
),
|
||||
OrgAddKind::Card { collection, title, holder, expiry, kind, tags, number_stdin, cvv_stdin, pin_stdin } => (
|
||||
collection,
|
||||
commands::org::OrgAddKind::Card { title, holder, expiry, kind, number_stdin, cvv_stdin, pin_stdin },
|
||||
tags,
|
||||
),
|
||||
OrgAddKind::Key { collection, title, label, algorithm, public_key, tags, material_stdin } => (
|
||||
collection,
|
||||
commands::org::OrgAddKind::Key { title, label, algorithm, public_key, material_stdin },
|
||||
tags,
|
||||
),
|
||||
OrgAddKind::Totp { collection, title, issuer, label, secret, period, digits, algorithm, tags, secret_stdin } => (
|
||||
collection,
|
||||
commands::org::OrgAddKind::Totp { title, issuer, label, secret, secret_stdin, period, digits, algorithm },
|
||||
tags,
|
||||
),
|
||||
};
|
||||
commands::org::run_add(&d, &collection, add_kind, tags)?;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user