transfer_family_cli 0.1.0

TUI to browse and transfer files via AWS Transfer Family connector
Documentation
//! Configuration for the Transfer Family Connector TUI CLI.

use std::path::PathBuf;

/// Runtime configuration derived from CLI args and env.
#[non_exhaustive]
#[derive(Clone, Debug)]
pub struct Config {
    /// AWS Transfer Family connector ID (e.g. `c-01234567890abcdef`).
    pub connector_id: String,
    /// S3 location for transfer CLI data: bucket and optional prefix, format `bucket/prefix`.
    /// Listings, retrieve, and send use subpaths under this root.
    pub s3_root: String,
    /// AWS region (e.g. `us-east-1`).
    pub region: Option<String>,
    /// AWS profile name for credentials.
    pub profile: Option<String>,
    /// Local directory for downloads (get). Default: current directory.
    pub download_dir: PathBuf,
}

impl Config {
    /// Builds config from individual fields (for use with `#[non_exhaustive]`).
    #[allow(clippy::missing_const_for_fn)] // String/PathBuf not const
    #[must_use]
    pub fn new(
        connector_id: String,
        s3_root: String,
        region: Option<String>,
        profile: Option<String>,
        download_dir: PathBuf,
    ) -> Self {
        Self {
            connector_id,
            s3_root,
            region,
            profile,
            download_dir,
        }
    }

    fn s3_base(&self) -> String {
        self.s3_root.trim_end_matches('/').to_string()
    }

    /// S3 path for directory listing results: `bucket/prefix/listings/`.
    #[must_use]
    pub fn listings_prefix(&self) -> String {
        format!("{}/listings/", self.s3_base())
    }

    /// S3 path for retrieve (get): `bucket/prefix/retrieve/`.
    #[must_use]
    pub fn retrieve_prefix(&self) -> String {
        format!("{}/retrieve/", self.s3_base())
    }

    /// S3 path for send (put): `bucket/prefix/send/`.
    #[must_use]
    pub fn send_prefix(&self) -> String {
        format!("{}/send/", self.s3_base())
    }
}