Module alfred::json [] [src]

Helpers for writing Alfred script filter JSON output (Alfred 3)

Example

JSON output (Alfred 3)

extern crate alfred;

use std::io::{self, Write};

fn write_items() -> io::Result<()> {
    alfred::json::write_items(io::stdout(), &[
        alfred::Item::new("Item 1"),
        alfred::ItemBuilder::new("Item 2")
                            .subtitle("Subtitle")
                            .into_item(),
        alfred::ItemBuilder::new("Item 3")
                            .arg("Argument")
                            .subtitle("Subtitle")
                            .icon_filetype("public.folder")
                            .into_item()
    ])
}

fn main() {
    match write_items() {
        Ok(()) => {},
        Err(err) => {
            let _ = writeln!(&mut io::stderr(), "Error writing items: {}", err);
        }
    }
}

Functions

write_items

Writes a complete JSON document representing the Items to the Write