xdiff-live 0.1.1

A live diff tool for comparing files and directories.
Documentation
//! # XDiff-NG: HTTP Request Comparison and Building Tools
//!
//! XDiff-NG is a powerful command-line toolkit for HTTP request comparison and construction.
//! It provides two main utilities:
//!
//! - **xdiff**: A sophisticated diff tool for comparing HTTP requests and responses
//! - **xreq**: A flexible HTTP request builder based on predefined profiles
//!
//! ## Features
//!
//! - Smart HTTP comparison with configurable skip rules
//! - Syntax highlighting for better readability
//! - YAML-based configuration with profile support
//! - High performance built with Rust
//! - Rich output formats and highlighting
//! - Extensible with custom profiles and configurations
//!
//! ## Example Usage
//!
//! ```no_run
//! use xdiff_live::{DiffConfig, ExtraArgs};
//!
//! # async fn example() -> Result<(), Box<dyn std::error::Error>> {
//! // Load configuration from YAML file
//! let config = DiffConfig::load_yaml("config.yml").await?;
//!
//! // Get a specific profile
//! let profile = config.get_profile("api_comparison").unwrap();
//!
//! // Create extra arguments for parameter override
//! let extra_args = ExtraArgs::new_with_query(vec![
//!     ("param1".to_string(), "value1".to_string()),
//! ]);
//!
//! // Perform the comparison
//! let diff_result = profile.diff(extra_args).await?;
//! println!("{}", diff_result);
//! # Ok(())
//! # }
//! ```

pub mod cli;
pub mod config;
mod utils;

pub use config::{
    get_body_text, get_headers_text, get_status_text, is_default, DiffConfig, DiffProfile,
    LoadConfig, RequestConfig, RequestProfile, ResponseProfile, ValidateConfig,
};
pub use utils::{diff_text, highlight_text, process_error_output};

/// Extra arguments for HTTP requests that can override or supplement
/// the base configuration from profiles.
///
/// This structure allows users to provide additional headers, query parameters,
/// and body parameters that will be merged with the profile configuration.
///
/// # Examples
///
/// ```
/// use xdiff_live::ExtraArgs;
///
/// // Create extra args with custom headers
/// let extra = ExtraArgs::new_with_headers(vec![
///     ("Authorization".to_string(), "Bearer token123".to_string()),
///     ("User-Agent".to_string(), "MyApp/1.0".to_string()),
/// ]);
///
/// // Create extra args with query parameters
/// let extra = ExtraArgs::new_with_query(vec![
///     ("page".to_string(), "1".to_string()),
///     ("limit".to_string(), "50".to_string()),
/// ]);
/// ```
#[derive(Debug, Default, Clone, PartialEq, Eq)]
pub struct ExtraArgs {
    /// Additional HTTP headers to include in the request
    pub headers: Vec<(String, String)>,
    /// Additional query parameters to include in the request URL
    pub query: Vec<(String, String)>,
    /// Additional body parameters to include in the request body
    pub body: Vec<(String, String)>,
}

impl ExtraArgs {
    /// Creates a new `ExtraArgs` instance with only headers specified.
    ///
    /// # Arguments
    ///
    /// * `headers` - A vector of key-value pairs representing HTTP headers
    ///
    /// # Examples
    ///
    /// ```
    /// use xdiff_live::ExtraArgs;
    ///
    /// let extra = ExtraArgs::new_with_headers(vec![
    ///     ("Content-Type".to_string(), "application/json".to_string()),
    /// ]);
    /// ```
    pub fn new_with_headers(headers: Vec<(String, String)>) -> Self {
        Self {
            headers,
            ..Default::default()
        }
    }

    /// Creates a new `ExtraArgs` instance with only query parameters specified.
    ///
    /// # Arguments
    ///
    /// * `query` - A vector of key-value pairs representing query parameters
    ///
    /// # Examples
    ///
    /// ```
    /// use xdiff_live::ExtraArgs;
    ///
    /// let extra = ExtraArgs::new_with_query(vec![
    ///     ("search".to_string(), "rust".to_string()),
    ///     ("page".to_string(), "1".to_string()),
    /// ]);
    /// ```
    pub fn new_with_query(query: Vec<(String, String)>) -> Self {
        Self {
            query,
            ..Default::default()
        }
    }

    /// Creates a new `ExtraArgs` instance with only body parameters specified.
    ///
    /// # Arguments
    ///
    /// * `body` - A vector of key-value pairs representing body parameters
    ///
    /// # Examples
    ///
    /// ```
    /// use xdiff_live::ExtraArgs;
    ///
    /// let extra = ExtraArgs::new_with_body(vec![
    ///     ("username".to_string(), "john_doe".to_string()),
    ///     ("email".to_string(), "john@example.com".to_string()),
    /// ]);
    /// ```
    pub fn new_with_body(body: Vec<(String, String)>) -> Self {
        Self {
            body,
            ..Default::default()
        }
    }
}