buildable 0.0.2

Buildable trait definition and utilities helpful in build lifecycles
//! Defines the `HgCommand` type.
//!
//! `HgCommand` wraps some commonly used `hg` commands for use with buildable.
//!
//! # Examples
//! ```rust
//! use buildable::scm::hg::{HgCommand};
//!
//! let hg_cmd = HgCommand::new();
//! ```
#![experimental]

//! `HgCommand` type definition.
pub struct HgCommand {
    wd: Option<Path>,
    env: Vec<(String,String)>,
    verbose: bool,
}

impl HgCommand {
    /// Create a new HgCommand.
    ///
    /// ```rust
    /// use buildable::scm::hg::HgCommand;
    ///
    /// let hg_cmd = HgCommand::new();
    /// ```
    pub fn new() -> HgCommand {
        HgCommand{ wd: None, env: Vec::new(), verbose: false }
    }

    /// Add a working directory to the HgCommand.
    ///
    /// ```rust
    /// use buildable::scm::hg::HgCommand;
    ///
    /// let mut hg_cmd = HgCommand::new();
    /// let wd = Path::new("/tmp");
    /// hg_cmd.wd(wd);  // Any following hg_cmd commands will execute in the
    ///                 // '/tmp' directory.
    /// ```
    ///
    /// # Arguments
    /// `wd` - The directory to execute the HgCommand in.
    ///
    /// # Notes
    /// * By default, the HgCommand is executed in the working directory
    /// of the parent process.
    pub fn wd(&mut self, wd: Path) -> &mut HgCommand {
        self.wd = Some(wd);
        self
    }

    pub fn env(&mut self, env: (String,String)) -> &mut HgCommand {
        self.env.push(env);
        self
    }

    pub fn verbose(&mut self, verbose: bool) -> &mut HgCommand {
        self.verbose = verbose;
        self
    }
}