Initial params loading
This commit is contained in:
parent
70c1df8e0a
commit
ce6f5300fd
|
@ -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
5
params.toml
Normal file
|
@ -0,0 +1,5 @@
|
|||
[global_flow]
|
||||
gen_decl = 0.4
|
||||
gen_subroutine = 0.3
|
||||
gen_typedef = 0.0
|
||||
gen_generation = 0.3
|
20
src/main.rs
20
src/main.rs
|
@ -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"]);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue