#command-line #trivial #utilities #pipelight #file #set #git

pipelight_utils

A set of trivial utilities for command line tools

8 releases

0.2.7 Aug 23, 2024
0.2.6 Aug 23, 2024
0.2.2 Jul 30, 2024

#4 in #trivial

Download history 91/week @ 2024-07-08 259/week @ 2024-07-29 78/week @ 2024-08-05 53/week @ 2024-08-12 554/week @ 2024-08-19 16/week @ 2024-08-26

705 downloads per month

GPL-2.0-only

60KB
1.5K SLoC

Pipelight utils crate

!! API not stabilized and lacking documentation !! !! Download at your own risks !!

A set of trivial utilities for command line tools.

These are the most cleaned up code modules from pipelight an automation cli.


lib.rs:

!! 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.

use pipelight_utils::teleport::Portal;

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

// Get the file path
let file_path = portal.target.file_path.clone().unwrap();
// Get the directory path
let directory_path = portal.target.directory_path.clone().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.



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

let res = toml::from_str::<Value>(&string);
match res {
    Ok(res) => Ok(res),
    Err(e) => {
        let err = TomlError::new(e, &string);
        return Err(err.into());
    }
};

pretty parsing error report

Git - easy git repo manipulation.

use pipelight_utils::git::Git;

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

Dependencies

~22–37MB
~610K SLoC