11mod essential;
22mod install;
3+ mod general;
34
4- use clap:: { Error , Parser , Subcommand } ;
5+ use clap:: { Error , Parser , Subcommand , Args } ;
56use clap:: command;
7+ use tracing:: debug;
68
79use crate :: essential:: { info, update_cli } ;
810use crate :: install:: install_cortexflow;
911
12+ use crate :: general:: GeneralData ;
13+
1014#[ derive( Parser , Debug ) ]
11- #[ command( author = "CortexFlow" , version = "0.1" , about = None , long_about = None ) ]
12- struct Args {
15+ #[ command(
16+ author = GeneralData :: AUTHOR ,
17+ version = GeneralData :: VERSION ,
18+ about = None ,
19+ long_about = None
20+ ) ]
21+ struct Cli {
1322 //name: String,
1423 #[ clap( subcommand) ]
1524 cmd : Option < Commands > ,
25+ env : String ,
1626}
1727
1828#[ derive( Subcommand , Debug , Clone ) ]
1929enum Commands {
2030 /* list of available commands */
31+ #[ command( name="set-env" ) ]
32+ SetEnv ( SetArgs ) ,
33+ #[ command( name="get-env" ) ]
34+ GetEnv ,
35+ #[ command( name="install" ) ]
2136 Install ,
37+ #[ command( name="update" ) ]
2238 Update ,
39+ #[ command( name="info" ) ]
2340 Info ,
2441}
42+ #[ derive( Args , Debug , Clone ) ]
43+ struct SetArgs {
44+ val : String ,
45+ }
2546
2647fn args_parser ( ) -> Result < ( ) , Error > {
27- let args = Args :: parse ( ) ;
28- println ! ( "Arguments {:?}" , args. cmd) ;
48+ let args = Cli :: parse ( ) ;
49+ let env = args. env ;
50+ let general_data = GeneralData :: new ( env) ;
51+ debug ! ( "Arguments {:?}" , args. cmd) ;
2952 match args. cmd {
53+ Some ( Commands :: SetEnv ( env) ) => {
54+ general_data. set_env ( env. val ) ;
55+ Ok ( ( ) )
56+ }
57+ Some ( Commands :: GetEnv ) => {
58+ general_data. get_env_output ( ) ;
59+ Ok ( ( ) )
60+ }
3061 Some ( Commands :: Install ) => {
3162 install_cortexflow ( ) ;
3263 Ok ( ( ) )
@@ -36,7 +67,7 @@ fn args_parser() -> Result<(), Error> {
3667 Ok ( ( ) )
3768 }
3869 Some ( Commands :: Info ) => {
39- info ( ) ;
70+ info ( general_data ) ;
4071 Ok ( ( ) )
4172 }
4273 None => {
0 commit comments