Skip to content

Commit cb33a7c

Browse files
committed
factor concat function
1 parent 7c9bbde commit cb33a7c

2 files changed

Lines changed: 25 additions & 4 deletions

File tree

src/lib.rs

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ fn extract_regex(re: &Regex, x: String) -> (String, String) {
5757
(
5858
x.replace(
5959
&caps["frames"],
60-
String::from_utf8(vec![b'*'; caps["frames"].len()])
60+
String::from_utf8(vec![b'#'; caps["frames"].len()])
6161
.unwrap()
6262
.as_str(),
6363
),
@@ -79,7 +79,7 @@ fn test_regex_simple() {
7979
let re = get_regex();
8080
let source: String = "RenderPass_Beauty_1_00000.exr".to_string();
8181
let expected: (String, String) = (
82-
"RenderPass_Beauty_1_*****.exr".to_string(),
82+
"RenderPass_Beauty_1_#####.exr".to_string(),
8383
"00000".to_string(),
8484
);
8585
assert_eq!(expected, extract_regex(&re, source))
@@ -124,7 +124,7 @@ fn test_parse_string() {
124124
let vec_toto: Vec<String> = vec!["001".to_string(), "002".to_string(), "003".to_string()];
125125
let vec_foo: Vec<String> = vec!["None".to_string()];
126126
let expected: HashMap<String, Vec<String>> = HashMap::from([
127-
("toto.***.tiff".to_string(), vec_toto),
127+
("toto.###.tiff".to_string(), vec_toto),
128128
("foo.exr".to_string(), vec_foo),
129129
]);
130130
assert_eq!(expected, parse_result(source));
@@ -195,6 +195,23 @@ fn create_frame_string(value: Vec<String>) -> String {
195195
let group_continuity: Vec<Vec<isize>> = group_continuity(&converted_vec_isize);
196196
convert_vec_to_str(group_continuity)
197197
}
198+
#[allow(dead_code)]
199+
fn concat_line(main_string: String, frame_string: String) -> String {
200+
let buf: bool = false;
201+
if buf {
202+
let from: String = String::from("#####");
203+
main_string.replace(&from, &frame_string)
204+
} else {
205+
format!("{}@{}", main_string, frame_string)
206+
}
207+
}
208+
#[test]
209+
fn test_concat_line() {
210+
let main_string: String = String::from("toto");
211+
let frame_string: String = String::from("bar");
212+
let expected: String = String::from("toto@bar");
213+
assert_eq!(expected, concat_line(main_string, frame_string));
214+
}
198215
/// ## Basic listing of the library
199216
/// ### Description
200217
///
@@ -235,7 +252,7 @@ pub fn extended_listing(root_path: String, frames: Vec<String>) -> Vec<String> {
235252
out_frames.push(key);
236253
} else {
237254
let to = value.first().unwrap();
238-
let from = String::from_utf8(vec![b'*'; to.len()]).unwrap();
255+
let from = String::from_utf8(vec![b'#'; to.len()]).unwrap();
239256
let new_path = &key.replace(&from, to);
240257
if re.is_match(new_path) {
241258
let path = format!("{}{}", root_path, new_path);

src/main.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ struct Args {
99
#[arg(short, long)]
1010
list: bool,
1111

12+
/// Display Buf format
13+
#[arg(short, long)]
14+
buf: bool,
15+
1216
/// Path to parse
1317
#[arg(default_value_t = String::from("./"), last = true)]
1418
path: String,

0 commit comments

Comments
 (0)