@@ -4,6 +4,7 @@ use anyhow::Result;
4
4
use clap:: { CommandFactory , Parser } ;
5
5
use human_panic:: setup_panic;
6
6
use onefetch:: cli:: { self , CliOptions } ;
7
+ use onefetch:: config:: ConfigOptions ;
7
8
use onefetch:: info:: build_info;
8
9
use onefetch:: ui:: printer:: Printer ;
9
10
use std:: io;
@@ -30,9 +31,25 @@ fn main() -> Result<()> {
30
31
return Ok ( ( ) ) ;
31
32
}
32
33
33
- let info = build_info ( & cli_options) ?;
34
+ if cli_options. config . generate_config {
35
+ return ConfigOptions :: default ( ) . write (
36
+ & cli_options. config . config_path . unwrap_or (
37
+ dirs:: config_dir ( )
38
+ . expect ( "Could not find config dir!" )
39
+ . join ( "onefetch/config.toml" ) ,
40
+ ) ,
41
+ ) ;
42
+ }
43
+
44
+ let config_options = ConfigOptions :: read (
45
+ & cli_options. config . config_path . as_ref ( ) . unwrap_or (
46
+ & CliOptions :: default ( ) . config . config_path . expect ( "$HOME not found!" )
47
+ ) ,
48
+ ) ;
49
+
50
+ let info = build_info ( & cli_options, & config_options) ?;
34
51
35
- let mut printer = Printer :: new ( io:: BufWriter :: new ( io:: stdout ( ) ) , info, cli_options) ?;
52
+ let mut printer = Printer :: new ( io:: BufWriter :: new ( io:: stdout ( ) ) , info, cli_options, config_options ) ?;
36
53
37
54
printer. print ( ) ?;
38
55
0 commit comments