3 releases
0.2.3 | Sep 23, 2024 |
---|---|
0.2.1 | Sep 23, 2024 |
0.2.0 | Sep 23, 2024 |
#760 in Text processing
54 downloads per month
Used in sqdj
12KB
205 lines
squidge
✨ Overview
squidge
shortens delimited data.
use squidge::{Config, shorten_line};
let line = "module/submodule/service/lib.rs";
let result = shorten_line(&Config::default(), &line);
let expected = vec!["m", "s", "s", "lib.rs"];
assert_eq!(result, expected);
squidge
's functionality is available as a binary via sqdj.
🛠️ Configuration
squidge
can be configured to shorten lines in varying ways, based on its
Config
.
use squidge::Config;
use regex::Regex;
let re = Regex::new("module").unwrap();
let cfg = Config {
// Delimiter to split the line on
delimiter: "\\",
// Number of elements to ignore (for shortening) from the start
ignore_first_n: 2,
// Number of elements to ignore (for shortening) from the end
ignore_last_n: 2,
// Optional regex to determine which components to ignore while shortening
ignore_regex: Some(re),
};
lib.rs
:
This crate provides functionality to shorten delimited data based on a given configuration.
Here's a quick example showing its usage:
use squidge::{Config, shorten_line};
let line = "module/submodule/service/lib.rs";
let result = shorten_line(&Config::default(), &line);
let expected = vec!["m", "s", "s", "lib.rs"];
assert_eq!(result, expected);
Dependencies
~2.2–3MB
~54K SLoC