@@ -6,12 +6,12 @@ use clap::builder::PossibleValuesParser;
6
6
use clap:: builder:: TypedValueParser as _;
7
7
use clap:: { value_parser, Args , Command , Parser , ValueHint } ;
8
8
use clap_complete:: { generate, Generator , Shell } ;
9
- use merge:: Merge ;
10
9
use num_format:: CustomFormat ;
11
10
use onefetch_image:: ImageProtocol ;
12
11
use onefetch_manifest:: ManifestType ;
13
12
use regex:: Regex ;
14
- use serde:: { de:: Visitor , Serializer , Deserialize , Serialize } ;
13
+ use serde:: Serialize ;
14
+ use merge:: Merge ;
15
15
use std:: env;
16
16
use std:: io;
17
17
use std:: path:: PathBuf ;
@@ -21,19 +21,17 @@ use strum::IntoEnumIterator;
21
21
const COLOR_RESOLUTIONS : [ & str ; 5 ] = [ "16" , "32" , "64" , "128" , "256" ] ;
22
22
pub const NO_BOTS_DEFAULT_REGEX_PATTERN : & str = r"(?:-|\s)[Bb]ot$|\[[Bb]ot\]" ;
23
23
24
- #[ derive( Clone , Debug , Parser , PartialEq , Eq , Merge , Serialize , Deserialize ) ]
24
+ #[ derive( Clone , Debug , Parser , PartialEq , Eq , Merge ) ]
25
25
#[ command( version, about) ]
26
26
pub struct CliOptions {
27
27
/// Run as if onefetch was started in <input> instead of the current working directory
28
28
#[ arg( default_value = "." , hide_default_value = true , value_hint = ValueHint :: DirPath ) ]
29
29
#[ merge( skip) ]
30
- #[ serde( skip) ]
31
30
pub input : PathBuf ,
32
31
/// Specify a custom path to a config file.
33
32
/// Default config is located at ${HOME}/.config/onefetch/config.conf.
34
33
#[ arg( long, value_hint = ValueHint :: AnyPath ) ]
35
34
#[ merge( skip) ]
36
- #[ serde( skip) ]
37
35
pub config_path : Option < PathBuf > ,
38
36
#[ command( flatten) ]
39
37
pub info : InfoCliOptions ,
@@ -51,7 +49,7 @@ pub struct CliOptions {
51
49
pub other : OtherCliOptions ,
52
50
}
53
51
54
- #[ derive( Clone , Debug , Args , PartialEq , Eq , Merge , Serialize , Deserialize ) ]
52
+ #[ derive( Clone , Debug , Args , PartialEq , Eq , Merge ) ]
55
53
#[ command( next_help_heading = "INFO" ) ]
56
54
pub struct InfoCliOptions {
57
55
/// Allows you to disable FIELD(s) from appearing in the output
@@ -134,7 +132,7 @@ pub struct InfoCliOptions {
134
132
pub r#type : Vec < LanguageType > ,
135
133
}
136
134
137
- #[ derive( Clone , Debug , Args , PartialEq , Eq , Merge , Serialize , Deserialize ) ]
135
+ #[ derive( Clone , Debug , Args , PartialEq , Eq , Merge ) ]
138
136
#[ command( next_help_heading = "ASCII" ) ]
139
137
pub struct AsciiCliOptions {
140
138
/// Takes a non-empty STRING as input to replace the ASCII logo
@@ -166,7 +164,6 @@ pub struct AsciiCliOptions {
166
164
hide_possible_values = true
167
165
) ]
168
166
#[ merge( skip) ]
169
- #[ serde( skip) ]
170
167
pub ascii_language : Option < Language > ,
171
168
/// Specify when to use true color
172
169
///
@@ -176,7 +173,7 @@ pub struct AsciiCliOptions {
176
173
pub true_color : When ,
177
174
}
178
175
179
- #[ derive( Clone , Debug , Args , PartialEq , Eq , Merge , Serialize , Deserialize ) ]
176
+ #[ derive( Clone , Debug , Args , PartialEq , Eq , Merge ) ]
180
177
#[ command( next_help_heading = "IMAGE" ) ]
181
178
pub struct ImageCliOptions {
182
179
/// Path to the IMAGE file
@@ -186,7 +183,6 @@ pub struct ImageCliOptions {
186
183
/// Which image PROTOCOL to use
187
184
#[ arg( long, value_enum, requires = "image" , value_name = "PROTOCOL" ) ]
188
185
#[ merge( skip) ]
189
- #[ serde( skip) ]
190
186
pub image_protocol : Option < ImageProtocol > ,
191
187
/// VALUE of color resolution to use with SIXEL backend
192
188
#[ arg(
@@ -201,7 +197,7 @@ pub struct ImageCliOptions {
201
197
pub color_resolution : usize ,
202
198
}
203
199
204
- #[ derive( Clone , Debug , Args , PartialEq , Eq , Merge , Serialize , Deserialize ) ]
200
+ #[ derive( Clone , Debug , Args , PartialEq , Eq , Merge ) ]
205
201
#[ command( next_help_heading = "TEXT FORMATTING" ) ]
206
202
pub struct TextForamttingCliOptions {
207
203
/// Changes the text colors (X X X...)
@@ -233,7 +229,7 @@ pub struct TextForamttingCliOptions {
233
229
#[ merge( strategy = merge:: bool :: overwrite_false) ]
234
230
pub no_bold : bool ,
235
231
}
236
- #[ derive( Clone , Debug , Args , PartialEq , Eq , Default , Merge , Serialize , Deserialize ) ]
232
+ #[ derive( Clone , Debug , Args , PartialEq , Eq , Default , Merge ) ]
237
233
#[ command( next_help_heading = "VISUALS" ) ]
238
234
pub struct VisualsCliOptions {
239
235
/// Hides the color palette
@@ -252,33 +248,29 @@ pub struct VisualsCliOptions {
252
248
pub nerd_fonts : bool ,
253
249
}
254
250
255
- #[ derive( Clone , Debug , Args , PartialEq , Eq , Default , Merge , Serialize , Deserialize ) ]
251
+ #[ derive( Clone , Debug , Args , PartialEq , Eq , Default , Merge ) ]
256
252
#[ command( next_help_heading = "DEVELOPER" ) ]
257
253
pub struct DeveloperCliOptions {
258
254
/// Outputs Onefetch in a specific format
259
255
#[ arg( long, short, value_name = "FORMAT" , value_enum) ]
260
256
#[ merge( skip) ]
261
- #[ serde( skip) ]
262
257
pub output : Option < SerializationFormat > ,
263
258
/// If provided, outputs the completion file for given SHELL
264
259
#[ arg( long = "generate" , value_name = "SHELL" , value_enum) ]
265
260
#[ merge( skip) ]
266
- #[ serde( skip) ]
267
261
pub completion : Option < Shell > ,
268
262
}
269
263
270
- #[ derive( Clone , Debug , Args , PartialEq , Eq , Default , Merge , Serialize , Deserialize ) ]
264
+ #[ derive( Clone , Debug , Args , PartialEq , Eq , Default , Merge ) ]
271
265
#[ command( next_help_heading = "OTHER" ) ]
272
266
pub struct OtherCliOptions {
273
267
/// Prints out supported languages
274
268
#[ arg( long, short) ]
275
269
#[ merge( skip) ]
276
- #[ serde( skip) ]
277
270
pub languages : bool ,
278
271
/// Prints out supported package managers
279
272
#[ arg( long, short) ]
280
273
#[ merge( skip) ]
281
- #[ serde( skip) ]
282
274
pub package_managers : bool ,
283
275
}
284
276
@@ -394,14 +386,14 @@ pub fn print_completions<G: Generator>(gen: G, cmd: &mut Command) {
394
386
generate ( gen, cmd, cmd. get_name ( ) . to_string ( ) , & mut io:: stdout ( ) ) ;
395
387
}
396
388
397
- #[ derive( clap:: ValueEnum , Clone , PartialEq , Eq , Debug , Serialize , Deserialize ) ]
389
+ #[ derive( clap:: ValueEnum , Clone , PartialEq , Eq , Debug ) ]
398
390
pub enum When {
399
391
Auto ,
400
392
Never ,
401
393
Always ,
402
394
}
403
395
404
- #[ derive( clap:: ValueEnum , Clone , PartialEq , Eq , Debug , Serialize , Deserialize , Copy ) ]
396
+ #[ derive( clap:: ValueEnum , Clone , PartialEq , Eq , Debug , Serialize , Copy ) ]
405
397
pub enum NumberSeparator {
406
398
Plain ,
407
399
Comma ,
@@ -520,37 +512,3 @@ impl FromStr for MyRegex {
520
512
Ok ( MyRegex ( Regex :: new ( s) ?) )
521
513
}
522
514
}
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