From 4477267905374f88d5992f7d1ea7c6a69e4d4c3a Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Mon, 11 May 2020 03:48:24 +0400 Subject: Генератор списка файлов "events.xml" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main.rs | 39 +++++++++++++++------------------------ 1 file changed, 15 insertions(+), 24 deletions(-) (limited to 'src/main.rs') diff --git a/src/main.rs b/src/main.rs index dbf0f28..f30f834 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,31 +1,22 @@ -#[macro_use] -extern crate serde_derive; -extern crate serde_json; +use walkdir::WalkDir; -extern crate clap; -extern crate xml; +/// Создание списка "events.xml" файлов. +fn get_list(root: &str) -> Vec { + let mut array: Vec = vec![]; -use std::fs::File; -use std::io::BufReader; -use std::path::Path; + for entry in WalkDir::new(root) { + let path = entry.unwrap().path().display().to_string(); -use clap::{load_yaml, App}; + if path.contains("events.xml") { + array.push(path); + } + } -mod parser; -use parser::*; + return array; +} fn main() { - let yaml = load_yaml!("cli/en.yml"); - let matches = App::from_yaml(yaml).get_matches(); - - let path = matches.value_of("FILE").unwrap(); - - match Path::new(path).exists() { - true => { - let file: File = File::open(path).unwrap(); - let data: ParserResult = parser(BufReader::new(file)); - println!("{}", serde_json::to_string_pretty(&data).unwrap()); - } - _ => panic!("File {:#?} does not exist or is not available.", path), - }; + let root = "tests"; + let list = get_list(root); + dbg!(list); } -- cgit v1.2.3