Fix the majority of the warnings

This commit is contained in:
Telesphoreo 2022-05-14 18:22:47 -05:00
parent 90bf442832
commit cb7dd9c6b8
No known key found for this signature in database
GPG Key ID: 5ACFFC4682CF849B

View File

@ -1,18 +1,14 @@
use std::{env, fs, io};
use std::borrow::Borrow;
use std::collections::{BTreeMap, BTreeSet, HashMap};
use std::fmt::format;
use std::io::{ErrorKind, Read, Write};
use std::ops::Index;
use std::collections::{BTreeMap};
use std::io::{Read};
use std::path::Path;
use yaml_rust::{Yaml, YamlEmitter, YamlLoader};
use yaml_rust::yaml::Array;
use yaml_rust::{Yaml, YamlLoader};
fn main() {
env::set_var("RUST_BACKTRACE", "full");
println!("Welcome to the IB Converter for converting TFM's indefinite bans file to Plex's!");
println!("Let's start off, please provide a path to TFM's indefinite bans file.");
println!("Welcome to IBConverter. This program converts TotalFreedomMod indefinite bans to Plex's format.");
println!("Path to TotalFreedomMod indefinite bans YAML file:");
// Path::new(".").read_dir().unwrap().for_each(|f| println!("{:?}", f.unwrap().file_name()));
let mut path = String::new();
io::stdin().read_line(&mut path).expect("Unable to parse this path.");
@ -26,14 +22,13 @@ fn main() {
io::stdin().read_line(&mut path).expect("Unable to parse this path.");
path = path.replace("\n", "").replace("\\n", "").replace("\r", "");
}
let fileData = fs::read_to_string(&path).expect("Unable to read this file! Perhaps it's corrupt or the file was not found.");
let yaml = &YamlLoader::load_from_str(&fileData).expect("This file couldn't be loaded as a YAML")[0];
let parentHash = yaml.as_hash().expect("Unable to load everything into a hash");
let file_data = fs::read_to_string(&path).expect("Unable to read this file! Perhaps it's corrupt or the file was not found.");
let yaml = &YamlLoader::load_from_str(&file_data).expect("This file couldn't be loaded as a YAML")[0];
let parent_hash = yaml.as_hash().expect("Unable to load everything into a hash");
let mut map: BTreeMap<usize, BTreeMap<String, Vec<String>>> = BTreeMap::new();
let mut index = 0;
for i in 0..parentHash.keys().len()
for i in 0..parent_hash.keys().len()
{
let k = parentHash.iter().skip(i).next().unwrap().0;
let k = parent_hash.iter().skip(i).next().unwrap().0;
println!("Key: {:?}", k);
let mut data: BTreeMap<String, Vec<String>> = BTreeMap::new();
let mut names: Vec<String> = Vec::new();
@ -45,7 +40,7 @@ fn main() {
names.push(str);
data.insert("users".to_string(), names);
}
let hash = parentHash[k].as_hash().expect("Couldn't load key as hash");
let hash = parent_hash[k].as_hash().expect("Couldn't load key as hash");
if hash.contains_key(&Yaml::String("uuid".to_string())) {
let mut uuids: Vec<String> = Vec::new();
uuids.push(hash.get(&Yaml::String("uuid".to_string())).unwrap().to_owned().into_string().unwrap());
@ -72,8 +67,4 @@ fn main() {
let mut stdin = io::stdin();
println!("Press any key to continue...");
let _ = stdin.read(&mut [0u8]).unwrap();
}
fn add_one(num: &mut i32) {
*num += 1;
}
}