docs, errors and basic api

This commit is contained in:
mycognosist
2021-11-03 15:52:35 +02:00
commit 97fc6cd3ff
6 changed files with 556 additions and 0 deletions

18
src/utils.rs Normal file
View File

@ -0,0 +1,18 @@
use regex::Regex;
use crate::SbotCliError;
/// Return matches for a given Regex pattern and text.
///
/// # Arguments
///
/// * `pattern` - A string slice representing a regular expression
/// * `input` - A string slice representing the input to be matched on
///
pub fn regex_finder(pattern: &str, input: &str) -> Result<Option<String>, SbotCliError> {
let re = Regex::new(pattern)?;
let caps = re.captures(input);
let result = caps.map(|caps| caps[1].to_string());
Ok(result)
}