瀏覽代碼

Read/write config files automatically

Samuel W. Flint 4 年之前
父節點
當前提交
f01994cad8
共有 1 個文件被更改,包括 10 次插入0 次删除
  1. 10 0
      src/main.rs

+ 10 - 0
src/main.rs

@@ -3,11 +3,19 @@ extern crate clap;
 use clap::App;
 
 mod config;
+use config::{
+    find_config_file,
+    read_configuration_file,
+    write_configuration_file,
+    Config
+};
 
 fn main() {
     let yaml = load_yaml!("cli.yml");
     let matches = App::from_yaml(yaml).get_matches();
 
+    let config_file = find_config_file(matches.value_of("config"));
+    let mut configuration: Config = read_configuration_file(&config_file);
     match matches.subcommand_name() {
         Some("run") => println!("Running..."), // if let Some(matches) = matches.subcommand_matches("run") {
         //     let names = matches.values_of("name").unwrap();
@@ -19,4 +27,6 @@ fn main() {
         Some(thing) => println!("{}", thing),
         _ => println!("No subcommand."),
     }
+
+    write_configuration_file(config_file, configuration);
 }