~savoy/mailcap

53909a089da9f7be86da4b403a8abf935fd368f4 — savoy 2 years ago 23e6548
field change from Entry.command -> viewer

To match the nomenclature of RFC 1524.

Signed-off-by: savoy <git@liberation.red>
1 files changed, 9 insertions(+), 9 deletions(-)

M src/lib.rs
M src/lib.rs => src/lib.rs +9 -9
@@ 38,7 38,7 @@ pub struct Mailcap {
#[derive(Default, Debug, PartialEq)]
pub struct Entry {
    mime_type: String,
    command: String,
    viewer: String,
    compose: Option<String>,
    compose_typed: Option<String>,
    edit: Option<String>,


@@ 184,7 184,7 @@ impl Entry {
        let mut entry = Entry::default();
        // TODO: validate mime_type against database
        entry.mime_type = line[0].to_owned();
        entry.command = line[1].to_owned();
        entry.viewer = line[1].to_owned();

        for field in line[2..].iter() {
            match Self::parse_arg(field) {


@@ 216,8 216,8 @@ impl Entry {
        &self.mime_type
    }

    pub fn command(&self) -> &String {
        &self.command
    pub fn viewer(&self) -> &String {
        &self.viewer
    }

    pub fn compose(&self) -> &Option<String> {


@@ 301,7 301,7 @@ mod tests {
            "text/html".to_string(),
            Entry {
                mime_type: "text/html".to_string(),
                command: "qutebrowser '%s'".to_string(),
                viewer: "qutebrowser '%s'".to_string(),
                compose: None,
                compose_typed: None,
                edit: None,


@@ 319,7 319,7 @@ mod tests {
            "text/*".to_string(),
            Entry {
                mime_type: "text/*".to_string(),
                command: "qutebrowser '%s'".to_string(),
                viewer: "qutebrowser '%s'".to_string(),
                compose: None,
                compose_typed: None,
                edit: None,


@@ 419,7 419,7 @@ mod tests {
        assert_eq!(
            Entry {
                mime_type: "text/html".to_string(),
                command: "qutebrowser '%s'".to_string(),
                viewer: "qutebrowser '%s'".to_string(),
                compose: None,
                compose_typed: None,
                edit: None,


@@ 449,7 449,7 @@ mod tests {
        let mailcap = Mailcap::new().unwrap();
        env::remove_var("MAILCAPS");
        if let Some(i) = mailcap.data.get("text/html") {
            assert_eq!(i.command, dummy_line.command)
            assert_eq!(i.viewer, dummy_line.viewer)
        }
    }



@@ 469,7 469,7 @@ mod tests {
        let mailcap = Mailcap::new().unwrap();
        env::remove_var("MAILCAPS");
        if let Some(i) = mailcap.data.get("text/html") {
            assert_eq!(i.command, dummy_line.command)
            assert_eq!(i.viewer, dummy_line.viewer)
        }
    }