@@ -6,12 +6,12 @@ use clap::builder::PossibleValuesParser;
66use clap:: builder:: TypedValueParser as _;
77use clap:: { value_parser, Args , Command , Parser , ValueHint } ;
88use clap_complete:: { generate, Generator , Shell } ;
9- use merge:: Merge ;
109use num_format:: CustomFormat ;
1110use onefetch_image:: ImageProtocol ;
1211use onefetch_manifest:: ManifestType ;
1312use regex:: Regex ;
14- use serde:: { de:: Visitor , Serializer , Deserialize , Serialize } ;
13+ use serde:: Serialize ;
14+ use merge:: Merge ;
1515use std:: env;
1616use std:: io;
1717use std:: path:: PathBuf ;
@@ -21,19 +21,17 @@ use strum::IntoEnumIterator;
2121const COLOR_RESOLUTIONS : [ & str ; 5 ] = [ "16" , "32" , "64" , "128" , "256" ] ;
2222pub const NO_BOTS_DEFAULT_REGEX_PATTERN : & str = r"(?:-|\s)[Bb]ot$|\[[Bb]ot\]" ;
2323
24- #[ derive( Clone , Debug , Parser , PartialEq , Eq , Merge , Serialize , Deserialize ) ]
24+ #[ derive( Clone , Debug , Parser , PartialEq , Eq , Merge ) ]
2525#[ command( version, about) ]
2626pub struct CliOptions {
2727 /// Run as if onefetch was started in <input> instead of the current working directory
2828 #[ arg( default_value = "." , hide_default_value = true , value_hint = ValueHint :: DirPath ) ]
2929 #[ merge( skip) ]
30- #[ serde( skip) ]
3130 pub input : PathBuf ,
3231 /// Specify a custom path to a config file.
3332 /// Default config is located at ${HOME}/.config/onefetch/config.conf.
3433 #[ arg( long, value_hint = ValueHint :: AnyPath ) ]
3534 #[ merge( skip) ]
36- #[ serde( skip) ]
3735 pub config_path : Option < PathBuf > ,
3836 #[ command( flatten) ]
3937 pub info : InfoCliOptions ,
@@ -51,7 +49,7 @@ pub struct CliOptions {
5149 pub other : OtherCliOptions ,
5250}
5351
54- #[ derive( Clone , Debug , Args , PartialEq , Eq , Merge , Serialize , Deserialize ) ]
52+ #[ derive( Clone , Debug , Args , PartialEq , Eq , Merge ) ]
5553#[ command( next_help_heading = "INFO" ) ]
5654pub struct InfoCliOptions {
5755 /// Allows you to disable FIELD(s) from appearing in the output
@@ -134,7 +132,7 @@ pub struct InfoCliOptions {
134132 pub r#type : Vec < LanguageType > ,
135133}
136134
137- #[ derive( Clone , Debug , Args , PartialEq , Eq , Merge , Serialize , Deserialize ) ]
135+ #[ derive( Clone , Debug , Args , PartialEq , Eq , Merge ) ]
138136#[ command( next_help_heading = "ASCII" ) ]
139137pub struct AsciiCliOptions {
140138 /// Takes a non-empty STRING as input to replace the ASCII logo
@@ -166,7 +164,6 @@ pub struct AsciiCliOptions {
166164 hide_possible_values = true
167165 ) ]
168166 #[ merge( skip) ]
169- #[ serde( skip) ]
170167 pub ascii_language : Option < Language > ,
171168 /// Specify when to use true color
172169 ///
@@ -176,7 +173,7 @@ pub struct AsciiCliOptions {
176173 pub true_color : When ,
177174}
178175
179- #[ derive( Clone , Debug , Args , PartialEq , Eq , Merge , Serialize , Deserialize ) ]
176+ #[ derive( Clone , Debug , Args , PartialEq , Eq , Merge ) ]
180177#[ command( next_help_heading = "IMAGE" ) ]
181178pub struct ImageCliOptions {
182179 /// Path to the IMAGE file
@@ -186,7 +183,6 @@ pub struct ImageCliOptions {
186183 /// Which image PROTOCOL to use
187184 #[ arg( long, value_enum, requires = "image" , value_name = "PROTOCOL" ) ]
188185 #[ merge( skip) ]
189- #[ serde( skip) ]
190186 pub image_protocol : Option < ImageProtocol > ,
191187 /// VALUE of color resolution to use with SIXEL backend
192188 #[ arg(
@@ -201,7 +197,7 @@ pub struct ImageCliOptions {
201197 pub color_resolution : usize ,
202198}
203199
204- #[ derive( Clone , Debug , Args , PartialEq , Eq , Merge , Serialize , Deserialize ) ]
200+ #[ derive( Clone , Debug , Args , PartialEq , Eq , Merge ) ]
205201#[ command( next_help_heading = "TEXT FORMATTING" ) ]
206202pub struct TextForamttingCliOptions {
207203 /// Changes the text colors (X X X...)
@@ -233,7 +229,7 @@ pub struct TextForamttingCliOptions {
233229 #[ merge( strategy = merge:: bool :: overwrite_false) ]
234230 pub no_bold : bool ,
235231}
236- #[ derive( Clone , Debug , Args , PartialEq , Eq , Default , Merge , Serialize , Deserialize ) ]
232+ #[ derive( Clone , Debug , Args , PartialEq , Eq , Default , Merge ) ]
237233#[ command( next_help_heading = "VISUALS" ) ]
238234pub struct VisualsCliOptions {
239235 /// Hides the color palette
@@ -252,33 +248,29 @@ pub struct VisualsCliOptions {
252248 pub nerd_fonts : bool ,
253249}
254250
255- #[ derive( Clone , Debug , Args , PartialEq , Eq , Default , Merge , Serialize , Deserialize ) ]
251+ #[ derive( Clone , Debug , Args , PartialEq , Eq , Default , Merge ) ]
256252#[ command( next_help_heading = "DEVELOPER" ) ]
257253pub struct DeveloperCliOptions {
258254 /// Outputs Onefetch in a specific format
259255 #[ arg( long, short, value_name = "FORMAT" , value_enum) ]
260256 #[ merge( skip) ]
261- #[ serde( skip) ]
262257 pub output : Option < SerializationFormat > ,
263258 /// If provided, outputs the completion file for given SHELL
264259 #[ arg( long = "generate" , value_name = "SHELL" , value_enum) ]
265260 #[ merge( skip) ]
266- #[ serde( skip) ]
267261 pub completion : Option < Shell > ,
268262}
269263
270- #[ derive( Clone , Debug , Args , PartialEq , Eq , Default , Merge , Serialize , Deserialize ) ]
264+ #[ derive( Clone , Debug , Args , PartialEq , Eq , Default , Merge ) ]
271265#[ command( next_help_heading = "OTHER" ) ]
272266pub struct OtherCliOptions {
273267 /// Prints out supported languages
274268 #[ arg( long, short) ]
275269 #[ merge( skip) ]
276- #[ serde( skip) ]
277270 pub languages : bool ,
278271 /// Prints out supported package managers
279272 #[ arg( long, short) ]
280273 #[ merge( skip) ]
281- #[ serde( skip) ]
282274 pub package_managers : bool ,
283275}
284276
@@ -394,14 +386,14 @@ pub fn print_completions<G: Generator>(gen: G, cmd: &mut Command) {
394386 generate ( gen, cmd, cmd. get_name ( ) . to_string ( ) , & mut io:: stdout ( ) ) ;
395387}
396388
397- #[ derive( clap:: ValueEnum , Clone , PartialEq , Eq , Debug , Serialize , Deserialize ) ]
389+ #[ derive( clap:: ValueEnum , Clone , PartialEq , Eq , Debug ) ]
398390pub enum When {
399391 Auto ,
400392 Never ,
401393 Always ,
402394}
403395
404- #[ derive( clap:: ValueEnum , Clone , PartialEq , Eq , Debug , Serialize , Deserialize , Copy ) ]
396+ #[ derive( clap:: ValueEnum , Clone , PartialEq , Eq , Debug , Serialize , Copy ) ]
405397pub enum NumberSeparator {
406398 Plain ,
407399 Comma ,
@@ -520,37 +512,3 @@ impl FromStr for MyRegex {
520512 Ok ( MyRegex ( Regex :: new ( s) ?) )
521513 }
522514}
523-
524- impl Serialize for MyRegex {
525- fn serialize < S > ( & self , serializer : S ) -> Result < S :: Ok , S :: Error >
526- where
527- S : Serializer ,
528- { serializer. serialize_str ( self . 0 . as_str ( ) ) }
529- }
530-
531- pub struct RegVisitor ;
532-
533- impl < ' de > Visitor < ' de > for RegVisitor {
534- type Value = MyRegex ;
535-
536- fn expecting ( & self , formatter : & mut std:: fmt:: Formatter ) -> std:: fmt:: Result {
537- formatter. write_str ( "regex" )
538- }
539-
540- fn visit_str < E > ( self , v : & str ) -> Result < Self :: Value , E >
541- where
542- E : serde:: de:: Error , {
543- match MyRegex :: from_str ( v) {
544- Ok ( regex) => Ok ( regex) ,
545- Err ( error) => Err ( serde:: de:: Error :: custom ( error) )
546- }
547- }
548- }
549-
550- impl < ' de > Deserialize < ' de > for MyRegex {
551- fn deserialize < D > ( deserializer : D ) -> Result < Self , D :: Error >
552- where
553- D : serde:: Deserializer < ' de > , {
554- deserializer. deserialize_str ( RegVisitor )
555- }
556- }
0 commit comments