Skip to main content

tsafe_cli/
lib.rs

1pub mod cli;
2pub mod explain;
3pub mod manpages;
4pub mod providers;
5#[cfg(feature = "cloud-pull-aws")]
6pub use providers::aws as tsafe_aws;
7#[cfg(feature = "cloud-pull-gcp")]
8pub use providers::gcp as tsafe_gcp;
9#[cfg(feature = "cloud-pull-vault")]
10pub use providers::hcp as tsafe_hcp;
11#[cfg(feature = "cloud-pull-keepass")]
12pub use providers::keepass as tsafe_keepass;
13#[cfg(feature = "cloud-pull-1password")]
14pub use providers::onepassword as tsafe_op;
15
16// Re-export the 1Password field-label normalisation function so that
17// integration tests can verify the mapping contract without shelling out
18// to `op`.
19#[cfg(any(feature = "cloud-pull-1password", feature = "cloud-pull-vault", test))]
20pub use op_mapping::op_field_label_to_key;
21
22// Always-compiled module that holds the pure mapping logic so it is
23// available for `#[cfg(test)]` regardless of feature flags.
24pub mod op_mapping {
25    /// Normalise a 1Password field label to an env-style vault key.
26    ///
27    /// Rule: spaces and hyphens → underscores, then uppercase.
28    /// The 1Password item name is **not** included in the output key.
29    ///
30    /// Examples:
31    /// - `"My Secret"` → `"MY_SECRET"`
32    /// - `"db-password"` → `"DB_PASSWORD"`
33    /// - `"API_KEY"` → `"API_KEY"`
34    pub fn op_field_label_to_key(label: &str) -> String {
35        label.replace([' ', '-'], "_").to_uppercase()
36    }
37}