File tree Expand file tree Collapse file tree 1 file changed +22
-1
lines changed Expand file tree Collapse file tree 1 file changed +22
-1
lines changed Original file line number Diff line number Diff line change 1
- use std:: env;
1
+ use std:: fs:: OpenOptions ;
2
+ use std:: { env, io:: Write } ;
2
3
3
4
use clap:: { App , Arg } ;
4
5
@@ -22,8 +23,28 @@ fn main() {
22
23
. help ( "config file" )
23
24
. takes_value ( true ) ,
24
25
)
26
+ . subcommand (
27
+ App :: new ( "init" )
28
+ . version ( VERSION )
29
+ . author ( "Inherd Group" )
30
+ . about ( "A DevOps Efficiency Analysis and Auto-suggestion Tool." ) ,
31
+ )
25
32
. get_matches ( ) ;
26
33
34
+ if matches. is_present ( "init" ) {
35
+ println ! ( "creating coco.yml" ) ;
36
+ match OpenOptions :: new ( )
37
+ . write ( true )
38
+ . create_new ( true )
39
+ . open ( "coco.yml" )
40
+ . map ( |mut file| file. write ( & serde_yaml:: to_vec ( & CocoConfig :: default ( ) ) . unwrap ( ) ) )
41
+ {
42
+ Ok ( _) => println ! ( "success created" ) ,
43
+ Err ( _) => println ! ( "coco.yml already exists" ) ,
44
+ }
45
+ std:: process:: exit ( 0 ) ;
46
+ }
47
+
27
48
let config_file = matches. value_of ( "config" ) . unwrap_or ( "coco.yml" ) ;
28
49
29
50
let cli_option = CocoCliOption :: default ( ) ;
You can’t perform that action at this time.
0 commit comments