Skip to content

Commit

Permalink
feat(coco): support for init subcommand
Browse files Browse the repository at this point in the history
  • Loading branch information
Eliot00 committed Feb 25, 2021
1 parent be6f143 commit 13b9434
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion src/bin/coco.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use std::env;
use std::fs::OpenOptions;
use std::{env, io::Write};

use clap::{App, Arg};

Expand All @@ -22,8 +23,28 @@ fn main() {
.help("config file")
.takes_value(true),
)
.subcommand(
App::new("init")
.version(VERSION)
.author("Inherd Group")
.about("A DevOps Efficiency Analysis and Auto-suggestion Tool."),
)
.get_matches();

if matches.is_present("init") {
println!("creating coco.yml");
match OpenOptions::new()
.write(true)
.create_new(true)
.open("coco.yml")
.map(|mut file| file.write(&serde_yaml::to_vec(&CocoConfig::default()).unwrap()))
{
Ok(_) => println!("success created"),
Err(_) => println!("coco.yml already exists"),
}
std::process::exit(0);
}

let config_file = matches.value_of("config").unwrap_or("coco.yml");

let cli_option = CocoCliOption::default();
Expand Down

0 comments on commit 13b9434

Please sign in to comment.