More updoots
Sorry future ben this commit message sucks
This commit is contained in:
parent
4aaa6601c2
commit
0a0ca87243
@ -6,6 +6,7 @@ edition = "2021"
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
glob = "0.3.1"
|
||||
serde = { version = "1.0.215", features = ["serde_derive"] }
|
||||
serde_json = "1.0.133"
|
||||
toml = "0.8.19"
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
use glob::glob;
|
||||
use std::fs::File;
|
||||
use std::io::prelude::*;
|
||||
|
||||
@ -14,3 +15,20 @@ pub fn load_file_contents(file_path: String) -> String {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn list_files(path: String, extension: String) -> Vec<String> {
|
||||
let mut tmp_path = path.clone();
|
||||
let mut files = Vec::<String>::new();
|
||||
let glob_path = format!("{}/*.{}", tmp_path, extension);
|
||||
// tmp_path.push_str(&glob_path);
|
||||
// println!("{}", glob_path);
|
||||
|
||||
for entry in glob(&glob_path).unwrap() {
|
||||
match entry {
|
||||
Ok(p) => files.push(String::from(p.display().to_string())),
|
||||
Err(e) => return vec![String::new()],
|
||||
}
|
||||
}
|
||||
|
||||
return files;
|
||||
}
|
||||
|
||||
@ -9,8 +9,17 @@ fn main() {
|
||||
let config = Config::load();
|
||||
|
||||
let pool = structs::BingoPool::load_from_file(String::from(
|
||||
"/home/ben/Documents/Projects/rust/BingoBongo/backend/workingdir/squares/testdata/testdata.toml",
|
||||
"/home/ben/Documents/Projects/rust/BingoBongo/backend/workingdir/pools/testdata.toml",
|
||||
));
|
||||
|
||||
// let pools = BingoPools::load_pools();
|
||||
|
||||
let files = files::list_files(
|
||||
String::from("/home/ben/Documents/Projects/rust/BingoBongo/backend/workingdir/pools"),
|
||||
String::from("toml"),
|
||||
);
|
||||
|
||||
println!("{:?}", files);
|
||||
|
||||
println!("{}", pool);
|
||||
}
|
||||
|
||||
@ -58,6 +58,18 @@ impl BingoPool {
|
||||
}
|
||||
}
|
||||
|
||||
pub struct BingoPools {
|
||||
pools: Vec<BingoPool>,
|
||||
}
|
||||
|
||||
impl BingoPools {
|
||||
pub fn load_pools() -> BingoPools {
|
||||
BingoPools {
|
||||
pools: Vec::<BingoPool>::new(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct BingoBoard {
|
||||
size: i64,
|
||||
squares: Vec<BingoSquare>,
|
||||
|
||||
18
backend/workingdir/pools/testdata.toml
Normal file
18
backend/workingdir/pools/testdata.toml
Normal file
@ -0,0 +1,18 @@
|
||||
[meta]
|
||||
name = 'Name of pool'
|
||||
description = 'Description of pool'
|
||||
|
||||
[[squares]]
|
||||
option = 'First square'
|
||||
|
||||
[[squares]]
|
||||
option = 'Second square'
|
||||
|
||||
[[squares]]
|
||||
option = 'Third square'
|
||||
|
||||
[[squares]]
|
||||
option = 'Fourth square'
|
||||
|
||||
[[squares]]
|
||||
option = 'Fifth square'
|
||||
@ -1,12 +0,0 @@
|
||||
[meta]
|
||||
name = 'Test Bingo'
|
||||
description = 'Because its fucking funny'
|
||||
|
||||
[[squares]]
|
||||
option = 'Code compiles first try and no one believes you'
|
||||
|
||||
[[squares]]
|
||||
option = 'There isnt a crate for that already'
|
||||
|
||||
[[squares]]
|
||||
option = 'Someone tells you to use JS'
|
||||
BIN
docs/Super_serious_design_docs.kra
Normal file
BIN
docs/Super_serious_design_docs.kra
Normal file
Binary file not shown.
BIN
docs/Super_serious_design_docs.png
Normal file
BIN
docs/Super_serious_design_docs.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 240 KiB |
Loading…
x
Reference in New Issue
Block a user