workmn 0.0.5

Manages the lifecycle of projects on the local machine
Documentation
mod load;
mod location;
mod project;
mod tag;

use project::*;
use tag::*;

pub use location::*;
pub use project::ProjectInfo;
pub use tag::TagInfo;

use std::collections::HashMap;

pub struct Conf {
    projects: HashMap<String, RawProject>,
    tags: HashMap<String, RawTag>,
    load_errors: Vec<String>,
}

impl Conf {
    pub fn projects(&self) -> Vec<ProjectInfo> {
        self.projects.values().map(ProjectInfo::new).collect()
    }

    pub fn project<S>(&self, name: S) -> Option<ProjectInfo>
    where
        S: AsRef<str>,
    {
        self.projects.get(name.as_ref()).map(ProjectInfo::new)
    }

    pub fn tags(&self) -> Vec<TagInfo> {
        self.tags.values().map(TagInfo::new).collect()
    }

    pub fn tag<S>(&self, name: S) -> Option<TagInfo>
    where
        S: AsRef<str>,
    {
        self.tags.get(name.as_ref()).map(TagInfo::new)
    }

    pub fn load_errors(&self) -> &Vec<String> {
        &self.load_errors
    }
}