refactor(cli): compress build_*_item with prompt_or_flag

Plan B Phase 3 sub-step 2. Replaces the
title.map(Ok).unwrap_or_else(|| prompt("Title"))? chain in all
seven build_*_item functions with prompt_or_flag, and folds
login's or_else(|| prompt_optional(...).ok().flatten()) for
username and url into prompt_or_flag_optional. prompt_secret
sites and the parse-on-Some-only patterns (expiry, dob, card
kind, totp algorithm) stay as-is per spec. Removes the
#[allow(dead_code)] attributes from the four helpers in
prompt.rs now that callers exist.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
adlee-was-taken
2026-05-09 11:12:26 -04:00
parent bfec232f11
commit 8e791e4853
2 changed files with 10 additions and 15 deletions

View File

@@ -80,8 +80,6 @@ pub(crate) fn prompt_yesno(label: &str) -> Result<bool> {
Ok(matches!(s.trim().to_ascii_lowercase().as_str(), "y" | "yes"))
}
// dead_code allowed until sub-step 2 wires these into commands/add.rs.
#[allow(dead_code)]
pub(crate) fn prompt_or_flag<T>(
flag: Option<T>,
label: &str,
@@ -92,7 +90,6 @@ pub(crate) fn prompt_or_flag<T>(
prompt_or_flag_with_reader(flag, label, parser, &mut reader)
}
#[allow(dead_code)]
pub(crate) fn prompt_or_flag_optional<T>(
flag: Option<T>,
label: &str,
@@ -103,7 +100,6 @@ pub(crate) fn prompt_or_flag_optional<T>(
prompt_or_flag_optional_with_reader(flag, label, parser, &mut reader)
}
#[allow(dead_code)]
pub(crate) fn prompt_or_flag_with_reader<T, R: BufRead>(
flag: Option<T>,
label: &str,
@@ -117,7 +113,6 @@ pub(crate) fn prompt_or_flag_with_reader<T, R: BufRead>(
parser(&line)
}
#[allow(dead_code)]
pub(crate) fn prompt_or_flag_optional_with_reader<T, R: BufRead>(
flag: Option<T>,
label: &str,