Crate pipelight_utils

source ·
Expand description

!! API not stabilized - lacking documentation - do not use !!

§About

Pipelight_utils is a crate that gather a set of trivial utilities for command line tools.

These are the most cleaned up modules coming from and named after pipelight, a tiny automation tool.

§Teleport - find a file recursively.

You can browse the filesystem for a configuration file.


let mut portal = Portal::new()?;
// Set a pattern to search for.
portal.seed("pipelight").search()?;

// Get the file path
portal.target.file_path.unwrap();
// Get the directory path
portal.target.directory_path.unwrap();

// Go to the target directory
portal.teleport()?;
// Go back to the origin directory
portal.origin()?;

§File - parse file types with pretty diagnostics.

Well structured parsing error reports with the language specific error types. thanks to the thiserror and miette crate.

Let say you want to deserialize to a Config struct.

use cast::Config;

let res = serde_yaml::from_str::<Config>(&string);
match res {
    Ok(res) => Ok(res),
    Err(e) => {
        let err = YamlError::new(e, &string);
        Err(err.into())
    }
}

let res = serde_toml::from_str::<Config>(&string);
match res {
    Ok(res) => Ok(res),
    Err(e) => {
        let err = TomlError::new(e, &string);
        Err(err.into())
    }
}
pretty parsing error report

§Git - easy git repo manipulation.


let repo = Git::new();
let branch = repo.get_branch()?;
let tag = repo.get_tag()?;
let commit = repo.get_commit()?;

Modules§