Initial params loading

This commit is contained in:
Akemi Izuko 2023-11-15 21:15:53 -07:00
parent 70c1df8e0a
commit ce6f5300fd
Signed by: akemi
GPG key ID: 8DE0764E1809E9FC
3 changed files with 25 additions and 2 deletions

View file

@ -6,3 +6,5 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
clap = { version = "4.4.8", features = ["derive"]}
toml = "0.8.8"

5
params.toml Normal file
View file

@ -0,0 +1,5 @@
[global_flow]
gen_decl = 0.4
gen_subroutine = 0.3
gen_typedef = 0.0
gen_generation = 0.3

View file

@ -1,3 +1,19 @@
fn main() {
println!("Hello, world!");
use std::fs;
use std::path::PathBuf;
use clap::Parser;
#[derive(Parser)]
#[command(author, version, about, long_about = None)]
struct Args {
config: PathBuf,
}
fn main() {
let args = Args::parse();
let params_toml = fs::read_to_string(&args.config)
.expect("Failed to read parameters file into string")
.parse::<toml::Table>()
.expect("Failed to parse TOML from parameters file");
println!("{}", params_toml["global_flow"]["gen_decl"]);
}