@@ -4,6 +4,7 @@ use anyhow::Result;
44use clap:: { CommandFactory , Parser } ;
55use human_panic:: setup_panic;
66use onefetch:: cli:: { self , CliOptions } ;
7+ use onefetch:: config:: ConfigOptions ;
78use onefetch:: info:: build_info;
89use onefetch:: ui:: printer:: Printer ;
910use std:: io;
@@ -30,9 +31,25 @@ fn main() -> Result<()> {
3031 return Ok ( ( ) ) ;
3132 }
3233
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) ?;
3451
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 ) ?;
3653
3754 printer. print ( ) ?;
3855
0 commit comments