~matthiasbeyer/imag

33a2c03ea8361ae61c162e307e10bc7266c1b249 — Matthias Beyer 10 months ago cd5dbbe
handlebars: 2 -> 3

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
M bin/core/imag-view/Cargo.toml => bin/core/imag-view/Cargo.toml +1 -1
@@ 23,7 23,7 @@ maintenance                       = { status     = "actively-developed" }
log = "0.4.6"
toml = "0.5.1"
toml-query = "0.10"
handlebars = "2"
handlebars = "3"
tempfile = "3.0.9"
anyhow = "1"
resiter = "0.4.0"

M bin/domain/imag-bookmark/Cargo.toml => bin/domain/imag-bookmark/Cargo.toml +1 -1
@@ 26,7 26,7 @@ toml-query = "0.10"
anyhow = "1"
resiter = "0.4.0"
url = "2"
handlebars = "2"
handlebars = "3"
rayon = "1"

libimagrt        = { version = "0.10.0", path = "../../../lib/core/libimagrt" }

M bin/domain/imag-calendar/Cargo.toml => bin/domain/imag-calendar/Cargo.toml +1 -1
@@ 26,7 26,7 @@ anyhow     = "1"
failure    = "0.1"
walkdir    = "2.2.8"
vobject    = "0.7"
handlebars = "2"
handlebars = "3"
chrono     = "0.4"
kairos     = "0.3"
resiter    = "0.4.0"

M bin/domain/imag-calendar/src/util.rs => bin/domain/imag-calendar/src/util.rs +2 -2
@@ 71,8 71,8 @@ impl<'a> ParsedEventFLE<'a> {
    }
}

pub fn get_event_print_format(config_value_path: &'static str, rt: &Runtime, scmd: &ArgMatches)
    -> Result<Handlebars>
pub fn get_event_print_format<'rc>(config_value_path: &'static str, rt: &Runtime, scmd: &ArgMatches)
    -> Result<Handlebars<'rc>>
{
    scmd.value_of("format")
        .map(String::from)

M bin/domain/imag-contact/Cargo.toml => bin/domain/imag-contact/Cargo.toml +1 -1
@@ 23,7 23,7 @@ maintenance                       = { status     = "actively-developed" }
log = "0.4.6"
toml = "0.5.1"
vobject    = "0.7.0"
handlebars = "2"
handlebars = "3"
walkdir = "2.2.8"
uuid = { version = "0.7.4", features = ["v4"] }
serde_json = "1.0.39"

M bin/domain/imag-contact/src/lib.rs => bin/domain/imag-contact/src/lib.rs +1 -1
@@ 380,7 380,7 @@ fn find(rt: &Runtime) -> Result<()> {
    }
}

fn get_contact_print_format(config_value_path: &'static str, rt: &Runtime, scmd: &ArgMatches) -> Result<Handlebars> {
fn get_contact_print_format<'rc>(config_value_path: &'static str, rt: &Runtime, scmd: &ArgMatches) -> Result<Handlebars<'rc>> {
    let fmt = match scmd.value_of("format").map(String::from) {
        Some(s) => Ok(s),
        None => rt.config()

M bin/domain/imag-mail/Cargo.toml => bin/domain/imag-mail/Cargo.toml +1 -1
@@ 23,7 23,7 @@ maintenance                       = { status     = "actively-developed" }
log = "0.4.6"
anyhow = "1"
resiter = "0.4"
handlebars = "2"
handlebars = "3"
walkdir = "2"
rayon = "1"


M bin/domain/imag-mail/src/util.rs => bin/domain/imag-mail/src/util.rs +1 -1
@@ 32,7 32,7 @@ use libimagrt::runtime::Runtime;
use libimagstore::store::FileLockEntry;
use libimagentryref::reference::Config as RefConfig;

pub fn get_mail_print_format(config_value_path: &'static str, rt: &Runtime, scmd: &ArgMatches) -> Result<Handlebars> {
pub fn get_mail_print_format<'rc>(config_value_path: &'static str, rt: &Runtime, scmd: &ArgMatches) -> Result<Handlebars<'rc>> {
    let fmt = match scmd.value_of("format").map(String::from) {
        Some(s) => Ok(s),
        None => {

M bin/domain/imag-todo/Cargo.toml => bin/domain/imag-todo/Cargo.toml +1 -1
@@ 29,7 29,7 @@ chrono = "0.4"
filters = "0.3"
kairos = "0.3"
resiter = "0.4.0"
handlebars = "2"
handlebars = "3"
prettytable-rs = "0.8.0"

libimagrt        = { version = "0.10.0", path = "../../../lib/core/libimagrt" }

M bin/domain/imag-todo/src/util.rs => bin/domain/imag-todo/src/util.rs +1 -1
@@ 38,7 38,7 @@ pub fn get_dt_str(d: Result<Option<NaiveDateTime>>, s: &str) -> Result<String> {
       .unwrap_or_else(|| s.to_string()))
}

pub fn get_todo_print_format(config_value_path: &'static str, rt: &Runtime, scmd: &ArgMatches) -> Result<Handlebars> {
pub fn get_todo_print_format<'rc>(config_value_path: &'static str, rt: &Runtime, scmd: &ArgMatches) -> Result<Handlebars<'rc>> {
    let fmt = match scmd.value_of("format").map(String::from) {
        Some(s) => Ok(s),
        None => {

M lib/core/libimagrt/Cargo.toml => lib/core/libimagrt/Cargo.toml +1 -1
@@ 48,7 48,7 @@ default-features = false
features = ["std", "serde"]

[dependencies.handlebars]
version          = "2"
version          = "3"
default-features = false
features         = ["no_logging"]


M lib/core/libimagrt/src/logger.rs => lib/core/libimagrt/src/logger.rs +5 -5
@@ 48,19 48,19 @@ impl Default for LogDestination {

/// Logger implementation for `log` crate.
#[derive(Debug)]
pub struct ImagLogger {
pub struct ImagLogger<'rc> {
    global_loglevel     : Level,

    #[allow(unused)]
    global_destinations : Vec<LogDestination>,

    handlebars: Handlebars,
    handlebars: Handlebars<'rc>,
}

impl ImagLogger {
impl<'rc> ImagLogger<'rc> {

    /// Create a new ImagLogger object with a certain level
    pub fn new(matches: &ArgMatches, config: Option<&Value>) -> Result<ImagLogger> {
    pub fn new(matches: &ArgMatches, config: Option<&Value>) -> Result<ImagLogger<'rc>> {
        let mut handlebars = Handlebars::new();

        handlebars.register_escape_fn(::handlebars::no_escape);


@@ 90,7 90,7 @@ impl ImagLogger {

}

impl Log for ImagLogger {
impl<'rc> Log for ImagLogger<'rc> {

    fn enabled(&self, metadata: &Metadata) -> bool {
        metadata.level() <= self.global_loglevel

M lib/etc/libimaginteraction/Cargo.toml => lib/etc/libimaginteraction/Cargo.toml +1 -1
@@ 26,7 26,7 @@ lazy_static = "1.3.0"
log = "0.4.6"
regex = "1.1.7"
toml = "0.5.1"
handlebars = "2"
handlebars = "3"
serde_json = "1.0.39"
serde_derive = "1"
serde = "1"

M lib/etc/libimaginteraction/src/format.rs => lib/etc/libimaginteraction/src/format.rs +16 -16
@@ 66,7 66,7 @@ impl From<String> for HandlebarsData {
pub struct ColorizeBlackHelper;

impl HelperDef for ColorizeBlackHelper {
    fn call<'reg: 'rc, 'rc>(&self, h: &Helper<'reg, 'rc>, _r: &'reg Registry, _ctx: &'rc Context, _rc: &mut RenderContext<'reg>, out: &mut dyn Output) -> Result<(), RenderError> {
    fn call<'reg: 'rc, 'rc>(&self, h: &Helper<'reg, 'rc>, _r: &'reg Registry, _ctx: &'rc Context, _rc: &mut RenderContext<'reg, 'rc>, out: &mut dyn Output) -> Result<(), RenderError> {
        colorize(Colour::Black, h, out)
    }
}


@@ 75,7 75,7 @@ impl HelperDef for ColorizeBlackHelper {
pub struct ColorizeBlueHelper;

impl HelperDef for ColorizeBlueHelper {
    fn call<'reg: 'rc, 'rc>(&self, h: &Helper<'reg, 'rc>, _r: &'reg Registry, _ctx: &'rc Context, _rc: &mut RenderContext<'reg>, out: &mut dyn Output) -> Result<(), RenderError> {
    fn call<'reg: 'rc, 'rc>(&self, h: &Helper<'reg, 'rc>, _r: &'reg Registry, _ctx: &'rc Context, _rc: &mut RenderContext<'reg, 'rc>, out: &mut dyn Output) -> Result<(), RenderError> {
        colorize(Colour::Blue, h, out)
    }
}


@@ 84,7 84,7 @@ impl HelperDef for ColorizeBlueHelper {
pub struct ColorizeCyanHelper;

impl HelperDef for ColorizeCyanHelper {
    fn call<'reg: 'rc, 'rc>(&self, h: &Helper<'reg, 'rc>, _r: &'reg Registry, _ctx: &'rc Context, _rc: &mut RenderContext<'reg>, out: &mut dyn Output) -> Result<(), RenderError> {
    fn call<'reg: 'rc, 'rc>(&self, h: &Helper<'reg, 'rc>, _r: &'reg Registry, _ctx: &'rc Context, _rc: &mut RenderContext<'reg, 'rc>, out: &mut dyn Output) -> Result<(), RenderError> {
        colorize(Colour::Cyan, h, out)
    }
}


@@ 93,7 93,7 @@ impl HelperDef for ColorizeCyanHelper {
pub struct ColorizeGreenHelper;

impl HelperDef for ColorizeGreenHelper {
    fn call<'reg: 'rc, 'rc>(&self, h: &Helper<'reg, 'rc>, _r: &'reg Registry, _ctx: &'rc Context, _rc: &mut RenderContext<'reg>, out: &mut dyn Output) -> Result<(), RenderError> {
    fn call<'reg: 'rc, 'rc>(&self, h: &Helper<'reg, 'rc>, _r: &'reg Registry, _ctx: &'rc Context, _rc: &mut RenderContext<'reg, 'rc>, out: &mut dyn Output) -> Result<(), RenderError> {
        colorize(Colour::Green, h, out)
    }
}


@@ 102,7 102,7 @@ impl HelperDef for ColorizeGreenHelper {
pub struct ColorizePurpleHelper;

impl HelperDef for ColorizePurpleHelper {
    fn call<'reg: 'rc, 'rc>(&self, h: &Helper<'reg, 'rc>, _r: &'reg Registry, _ctx: &'rc Context, _rc: &mut RenderContext<'reg>, out: &mut dyn Output) -> Result<(), RenderError> {
    fn call<'reg: 'rc, 'rc>(&self, h: &Helper<'reg, 'rc>, _r: &'reg Registry, _ctx: &'rc Context, _rc: &mut RenderContext<'reg, 'rc>, out: &mut dyn Output) -> Result<(), RenderError> {
        colorize(Colour::Purple, h, out)
    }
}


@@ 111,7 111,7 @@ impl HelperDef for ColorizePurpleHelper {
pub struct ColorizeRedHelper;

impl HelperDef for ColorizeRedHelper {
    fn call<'reg: 'rc, 'rc>(&self, h: &Helper<'reg, 'rc>, _r: &'reg Registry, _ctx: &'rc Context, _rc: &mut RenderContext<'reg>, out: &mut dyn Output) -> Result<(), RenderError> {
    fn call<'reg: 'rc, 'rc>(&self, h: &Helper<'reg, 'rc>, _r: &'reg Registry, _ctx: &'rc Context, _rc: &mut RenderContext<'reg, 'rc>, out: &mut dyn Output) -> Result<(), RenderError> {
        colorize(Colour::Red, h, out)
    }
}


@@ 120,7 120,7 @@ impl HelperDef for ColorizeRedHelper {
pub struct ColorizeWhiteHelper;

impl HelperDef for ColorizeWhiteHelper {
    fn call<'reg: 'rc, 'rc>(&self, h: &Helper<'reg, 'rc>, _r: &'reg Registry, _ctx: &'rc Context, _rc: &mut RenderContext<'reg>, out: &mut dyn Output) -> Result<(), RenderError> {
    fn call<'reg: 'rc, 'rc>(&self, h: &Helper<'reg, 'rc>, _r: &'reg Registry, _ctx: &'rc Context, _rc: &mut RenderContext<'reg, 'rc>, out: &mut dyn Output) -> Result<(), RenderError> {
        colorize(Colour::White, h, out)
    }
}


@@ 129,7 129,7 @@ impl HelperDef for ColorizeWhiteHelper {
pub struct ColorizeYellowHelper;

impl HelperDef for ColorizeYellowHelper {
    fn call<'reg: 'rc, 'rc>(&self, h: &Helper<'reg, 'rc>, _r: &'reg Registry, _ctx: &'rc Context, _rc: &mut RenderContext<'reg>, out: &mut dyn Output) -> Result<(), RenderError> {
    fn call<'reg: 'rc, 'rc>(&self, h: &Helper<'reg, 'rc>, _r: &'reg Registry, _ctx: &'rc Context, _rc: &mut RenderContext<'reg, 'rc>, out: &mut dyn Output) -> Result<(), RenderError> {
        colorize(Colour::Yellow, h, out)
    }
}


@@ 146,7 146,7 @@ fn colorize(color: Colour, h: &Helper, output: &mut dyn Output) -> Result<(), Re
pub struct UnderlineHelper;

impl HelperDef for UnderlineHelper {
    fn call<'reg: 'rc, 'rc>(&self, h: &Helper<'reg, 'rc>, _r: &'reg Registry, _ctx: &'rc Context, _rc: &mut RenderContext<'reg>, out: &mut dyn Output) -> Result<(), RenderError> {
    fn call<'reg: 'rc, 'rc>(&self, h: &Helper<'reg, 'rc>, _r: &'reg Registry, _ctx: &'rc Context, _rc: &mut RenderContext<'reg, 'rc>, out: &mut dyn Output) -> Result<(), RenderError> {
            let p = h.param(0).ok_or_else(|| RenderError::new("Too few arguments"))?;
            let s = Style::new().underline();
            out.write(&format!("{}", s.paint(p.value().render())))?;


@@ 158,7 158,7 @@ impl HelperDef for UnderlineHelper {
pub struct BoldHelper;

impl HelperDef for BoldHelper {
    fn call<'reg: 'rc, 'rc>(&self, h: &Helper<'reg, 'rc>, _r: &'reg Registry, _ctx: &'rc Context, _rc: &mut RenderContext<'reg>, out: &mut dyn Output) -> Result<(), RenderError> {
    fn call<'reg: 'rc, 'rc>(&self, h: &Helper<'reg, 'rc>, _r: &'reg Registry, _ctx: &'rc Context, _rc: &mut RenderContext<'reg, 'rc>, out: &mut dyn Output) -> Result<(), RenderError> {
            let p = h.param(0).ok_or_else(|| RenderError::new("Too few arguments"))?;
            let s = Style::new().bold();
            out.write(&format!("{}", s.paint(p.value().render())))?;


@@ 170,7 170,7 @@ impl HelperDef for BoldHelper {
pub struct BlinkHelper;

impl HelperDef for BlinkHelper {
    fn call<'reg: 'rc, 'rc>(&self, h: &Helper<'reg, 'rc>, _r: &'reg Registry, _ctx: &'rc Context, _rc: &mut RenderContext<'reg>, out: &mut dyn Output) -> Result<(), RenderError> {
    fn call<'reg: 'rc, 'rc>(&self, h: &Helper<'reg, 'rc>, _r: &'reg Registry, _ctx: &'rc Context, _rc: &mut RenderContext<'reg, 'rc>, out: &mut dyn Output) -> Result<(), RenderError> {
            let p = h.param(0).ok_or_else(|| RenderError::new("Too few arguments"))?;
            let s = Style::new().blink();
            out.write(&format!("{}", s.paint(p.value().render())))?;


@@ 182,7 182,7 @@ impl HelperDef for BlinkHelper {
pub struct StrikethroughHelper;

impl HelperDef for StrikethroughHelper {
    fn call<'reg: 'rc, 'rc>(&self, h: &Helper<'reg, 'rc>, _r: &'reg Registry, _ctx: &'rc Context, _rc: &mut RenderContext<'reg>, out: &mut dyn Output) -> Result<(), RenderError> {
    fn call<'reg: 'rc, 'rc>(&self, h: &Helper<'reg, 'rc>, _r: &'reg Registry, _ctx: &'rc Context, _rc: &mut RenderContext<'reg, 'rc>, out: &mut dyn Output) -> Result<(), RenderError> {
            let p = h.param(0).ok_or_else(|| RenderError::new("Too few arguments"))?;
            let s = Style::new().strikethrough();
            out.write(&format!("{}", s.paint(p.value().render())))?;


@@ 215,7 215,7 @@ fn param_to_number(idx: usize, h: &Helper) -> Result<u64, RenderError> {
pub struct LeftPadHelper;

impl HelperDef for LeftPadHelper {
    fn call<'reg: 'rc, 'rc>(&self, h: &Helper<'reg, 'rc>, _r: &'reg Registry, _ctx: &'rc Context, _rc: &mut RenderContext<'reg>, out: &mut dyn Output) -> Result<(), RenderError> {
    fn call<'reg: 'rc, 'rc>(&self, h: &Helper<'reg, 'rc>, _r: &'reg Registry, _ctx: &'rc Context, _rc: &mut RenderContext<'reg, 'rc>, out: &mut dyn Output) -> Result<(), RenderError> {
        let count = param_to_number(0, h)? as usize;
        let text = h.param(1).ok_or_else(|| RenderError::new("Too few arguments"))?;
        let text = format!("{:>width$}", text.value().render(), width = count);


@@ 228,7 228,7 @@ impl HelperDef for LeftPadHelper {
pub struct RightPadHelper;

impl HelperDef for RightPadHelper {
    fn call<'reg: 'rc, 'rc>(&self, h: &Helper<'reg, 'rc>, _r: &'reg Registry, _ctx: &'rc Context, _rc: &mut RenderContext<'reg>, out: &mut dyn Output) -> Result<(), RenderError> {
    fn call<'reg: 'rc, 'rc>(&self, h: &Helper<'reg, 'rc>, _r: &'reg Registry, _ctx: &'rc Context, _rc: &mut RenderContext<'reg, 'rc>, out: &mut dyn Output) -> Result<(), RenderError> {
        let count = param_to_number(0, h)? as usize;
        let text = h.param(1).ok_or_else(|| RenderError::new("Too few arguments"))?;
        let text = format!("{:width$}", text.value().render(), width = count);


@@ 241,7 241,7 @@ impl HelperDef for RightPadHelper {
pub struct AbbrevHelper;

impl HelperDef for AbbrevHelper {
    fn call<'reg: 'rc, 'rc>(&self, h: &Helper<'reg, 'rc>, _r: &'reg Registry, _ctx: &'rc Context, _rc: &mut RenderContext<'reg>, out: &mut dyn Output) -> Result<(), RenderError> {
    fn call<'reg: 'rc, 'rc>(&self, h: &Helper<'reg, 'rc>, _r: &'reg Registry, _ctx: &'rc Context, _rc: &mut RenderContext<'reg, 'rc>, out: &mut dyn Output) -> Result<(), RenderError> {
        let count = param_to_number(0, h)? as usize;
        let text = h.param(1).ok_or_else(|| RenderError::new("Too few arguments"))?.value().render();
        out.write(&text.chars().take(count).collect::<String>())?;


@@ 254,7 254,7 @@ impl HelperDef for AbbrevHelper {
pub struct IndentionHelper;

impl HelperDef for IndentionHelper {
    fn call<'reg: 'rc, 'rc>(&self, h: &Helper<'reg, 'rc>, _r: &'reg Registry, _ctx: &'rc Context, _rc: &mut RenderContext<'reg>, out: &mut dyn Output) -> Result<(), RenderError> {
    fn call<'reg: 'rc, 'rc>(&self, h: &Helper<'reg, 'rc>, _r: &'reg Registry, _ctx: &'rc Context, _rc: &mut RenderContext<'reg, 'rc>, out: &mut dyn Output) -> Result<(), RenderError> {
        let count = param_to_number(0, h)? as usize;
        let text = h.param(1).ok_or_else(|| RenderError::new("Too few arguments"))?.value().render();
        out.write(&::std::iter::repeat(text).take(count).collect::<String>())?;