@@ -11,7 +11,6 @@ use onefetch_image::ImageProtocol;
11
11
use onefetch_manifest:: ManifestType ;
12
12
use regex:: Regex ;
13
13
use serde:: Serialize ;
14
- use merge:: Merge ;
15
14
use std:: env;
16
15
use std:: io;
17
16
use std:: path:: PathBuf ;
@@ -21,18 +20,12 @@ use strum::IntoEnumIterator;
21
20
const COLOR_RESOLUTIONS : [ & str ; 5 ] = [ "16" , "32" , "64" , "128" , "256" ] ;
22
21
pub const NO_BOTS_DEFAULT_REGEX_PATTERN : & str = r"(?:-|\s)[Bb]ot$|\[[Bb]ot\]" ;
23
22
24
- #[ derive( Clone , Debug , Parser , PartialEq , Eq , Merge ) ]
23
+ #[ derive( Clone , Debug , Parser , PartialEq , Eq ) ]
25
24
#[ command( version, about) ]
26
25
pub struct CliOptions {
27
26
/// Run as if onefetch was started in <input> instead of the current working directory
28
27
#[ arg( default_value = "." , hide_default_value = true , value_hint = ValueHint :: DirPath ) ]
29
- #[ merge( skip) ]
30
28
pub input : PathBuf ,
31
- /// Specify a custom path to a config file.
32
- /// Default config is located at ${HOME}/.config/onefetch/config.conf.
33
- #[ arg( long, value_hint = ValueHint :: AnyPath ) ]
34
- #[ merge( skip) ]
35
- pub config_path : Option < PathBuf > ,
36
29
#[ command( flatten) ]
37
30
pub info : InfoCliOptions ,
38
31
#[ command( flatten) ]
@@ -49,7 +42,7 @@ pub struct CliOptions {
49
42
pub other : OtherCliOptions ,
50
43
}
51
44
52
- #[ derive( Clone , Debug , Args , PartialEq , Eq , Merge ) ]
45
+ #[ derive( Clone , Debug , Args , PartialEq , Eq ) ]
53
46
#[ command( next_help_heading = "INFO" ) ]
54
47
pub struct InfoCliOptions {
55
48
/// Allows you to disable FIELD(s) from appearing in the output
@@ -61,34 +54,27 @@ pub struct InfoCliOptions {
61
54
value_enum,
62
55
value_name = "FIELD"
63
56
) ]
64
- #[ merge( strategy = overwrite_vec) ]
65
57
pub disabled_fields : Vec < InfoType > ,
66
58
/// Hides the title
67
59
#[ arg( long) ]
68
- #[ merge( strategy = merge:: bool :: overwrite_false) ]
69
60
pub no_title : bool ,
70
61
/// Maximum NUM of authors to be shown
71
62
#[ arg( long, default_value_t = 3usize , value_name = "NUM" ) ]
72
- #[ merge( strategy = overwrite) ]
73
63
pub number_of_authors : usize ,
74
64
/// Maximum NUM of languages to be shown
75
65
#[ arg( long, default_value_t = 6usize , value_name = "NUM" ) ]
76
- #[ merge( strategy = overwrite) ]
77
66
pub number_of_languages : usize ,
78
67
/// Maximum NUM of file churns to be shown
79
68
#[ arg( long, default_value_t = 3usize , value_name = "NUM" ) ]
80
- #[ merge( strategy = overwrite) ]
81
69
pub number_of_file_churns : usize ,
82
70
/// Minimum NUM of commits from HEAD used to compute the churn summary
83
71
///
84
72
/// By default, the actual value is non-deterministic due to time-based computation
85
73
/// and will be displayed under the info title "Churn (NUM)"
86
74
#[ arg( long, value_name = "NUM" ) ]
87
- #[ merge( strategy = overwrite) ]
88
75
pub churn_pool_size : Option < usize > ,
89
76
/// Ignore all files & directories matching EXCLUDE
90
77
#[ arg( long, short, num_args = 1 ..) ]
91
- #[ merge( strategy = overwrite_vec) ]
92
78
pub exclude : Vec < String > ,
93
79
/// Exclude [bot] commits. Use <REGEX> to override the default pattern
94
80
#[ arg(
@@ -98,27 +84,21 @@ pub struct InfoCliOptions {
98
84
default_missing_value = NO_BOTS_DEFAULT_REGEX_PATTERN ,
99
85
value_name = "REGEX"
100
86
) ]
101
- #[ merge( strategy = overwrite) ]
102
87
pub no_bots : Option < MyRegex > ,
103
88
/// Ignores merge commits
104
89
#[ arg( long) ]
105
- #[ merge( strategy = merge:: bool :: overwrite_false) ]
106
90
pub no_merges : bool ,
107
91
/// Show the email address of each author
108
92
#[ arg( long, short = 'E' ) ]
109
- #[ merge( strategy = merge:: bool :: overwrite_false) ]
110
93
pub email : bool ,
111
94
/// Display repository URL as HTTP
112
95
#[ arg( long) ]
113
- #[ merge( strategy = merge:: bool :: overwrite_false) ]
114
96
pub http_url : bool ,
115
97
/// Hide token in repository URL
116
98
#[ arg( long) ]
117
- #[ merge( strategy = merge:: bool :: overwrite_false) ]
118
99
pub hide_token : bool ,
119
100
/// Count hidden files and directories
120
101
#[ arg( long) ]
121
- #[ merge( strategy = merge:: bool :: overwrite_false) ]
122
102
pub include_hidden : bool ,
123
103
/// Filters output by language type
124
104
#[ arg(
@@ -128,11 +108,10 @@ pub struct InfoCliOptions {
128
108
short = 'T' ,
129
109
value_enum,
130
110
) ]
131
- #[ merge( strategy = overwrite_vec) ]
132
111
pub r#type : Vec < LanguageType > ,
133
112
}
134
113
135
- #[ derive( Clone , Debug , Args , PartialEq , Eq , Merge ) ]
114
+ #[ derive( Clone , Debug , Args , PartialEq , Eq ) ]
136
115
#[ command( next_help_heading = "ASCII" ) ]
137
116
pub struct AsciiCliOptions {
138
117
/// Takes a non-empty STRING as input to replace the ASCII logo
@@ -143,7 +122,6 @@ pub struct AsciiCliOptions {
143
122
///
144
123
/// '--ascii-input "$(fortune | cowsay -W 25)"'
145
124
#[ arg( long, value_name = "STRING" , value_hint = ValueHint :: CommandString ) ]
146
- #[ merge( strategy = overwrite) ]
147
125
pub ascii_input : Option < String > ,
148
126
/// Colors (X X X...) to print the ascii art
149
127
#[ arg(
@@ -153,7 +131,6 @@ pub struct AsciiCliOptions {
153
131
short = 'c' ,
154
132
value_parser = value_parser!( u8 ) . range( ..16 ) ,
155
133
) ]
156
- #[ merge( strategy = overwrite_vec) ]
157
134
pub ascii_colors : Vec < u8 > ,
158
135
/// Which LANGUAGE's ascii art to print
159
136
#[ arg(
@@ -163,26 +140,22 @@ pub struct AsciiCliOptions {
163
140
value_enum,
164
141
hide_possible_values = true
165
142
) ]
166
- #[ merge( skip) ]
167
143
pub ascii_language : Option < Language > ,
168
144
/// Specify when to use true color
169
145
///
170
146
/// If set to auto: true color will be enabled if supported by the terminal
171
147
#[ arg( long, default_value = "auto" , value_name = "WHEN" , value_enum) ]
172
- #[ merge( strategy = overwrite) ]
173
148
pub true_color : When ,
174
149
}
175
150
176
- #[ derive( Clone , Debug , Args , PartialEq , Eq , Merge ) ]
151
+ #[ derive( Clone , Debug , Args , PartialEq , Eq ) ]
177
152
#[ command( next_help_heading = "IMAGE" ) ]
178
153
pub struct ImageCliOptions {
179
154
/// Path to the IMAGE file
180
155
#[ arg( long, short, value_hint = ValueHint :: FilePath ) ]
181
- #[ merge( strategy = overwrite) ]
182
156
pub image : Option < PathBuf > ,
183
157
/// Which image PROTOCOL to use
184
158
#[ arg( long, value_enum, requires = "image" , value_name = "PROTOCOL" ) ]
185
- #[ merge( skip) ]
186
159
pub image_protocol : Option < ImageProtocol > ,
187
160
/// VALUE of color resolution to use with SIXEL backend
188
161
#[ arg(
@@ -193,11 +166,10 @@ pub struct ImageCliOptions {
193
166
value_parser = PossibleValuesParser :: new( COLOR_RESOLUTIONS )
194
167
. map( |s| s. parse:: <usize >( ) . unwrap( ) )
195
168
) ]
196
- #[ merge( strategy = overwrite) ]
197
169
pub color_resolution : usize ,
198
170
}
199
171
200
- #[ derive( Clone , Debug , Args , PartialEq , Eq , Merge ) ]
172
+ #[ derive( Clone , Debug , Args , PartialEq , Eq ) ]
201
173
#[ command( next_help_heading = "TEXT FORMATTING" ) ]
202
174
pub struct TextForamttingCliOptions {
203
175
/// Changes the text colors (X X X...)
@@ -214,71 +186,59 @@ pub struct TextForamttingCliOptions {
214
186
value_parser = value_parser!( u8 ) . range( ..16 ) ,
215
187
num_args = 1 ..=6
216
188
) ]
217
- #[ merge( strategy = overwrite_vec) ]
218
189
pub text_colors : Vec < u8 > ,
219
190
/// Use ISO 8601 formatted timestamps
220
191
#[ arg( long, short = 'z' ) ]
221
- #[ merge( strategy = merge:: bool :: overwrite_false) ]
222
192
pub iso_time : bool ,
223
193
/// Which thousands SEPARATOR to use
224
194
#[ arg( long, value_name = "SEPARATOR" , default_value = "plain" , value_enum) ]
225
- #[ merge( strategy = overwrite) ]
226
195
pub number_separator : NumberSeparator ,
227
196
/// Turns off bold formatting
228
197
#[ arg( long) ]
229
- #[ merge( strategy = merge:: bool :: overwrite_false) ]
230
198
pub no_bold : bool ,
231
199
}
232
- #[ derive( Clone , Debug , Args , PartialEq , Eq , Default , Merge ) ]
200
+ #[ derive( Clone , Debug , Args , PartialEq , Eq , Default ) ]
233
201
#[ command( next_help_heading = "VISUALS" ) ]
234
202
pub struct VisualsCliOptions {
235
203
/// Hides the color palette
236
204
#[ arg( long) ]
237
- #[ merge( strategy = merge:: bool :: overwrite_false) ]
238
205
pub no_color_palette : bool ,
239
206
/// Hides the ascii art or image if provided
240
207
#[ arg( long) ]
241
- #[ merge( strategy = merge:: bool :: overwrite_false) ]
242
208
pub no_art : bool ,
243
209
/// Use Nerd Font icons
244
210
///
245
211
/// Replaces language chips with Nerd Font icons
246
212
#[ arg( long) ]
247
- #[ merge( strategy = merge:: bool :: overwrite_false) ]
248
213
pub nerd_fonts : bool ,
249
214
}
250
215
251
- #[ derive( Clone , Debug , Args , PartialEq , Eq , Default , Merge ) ]
216
+ #[ derive( Clone , Debug , Args , PartialEq , Eq , Default ) ]
252
217
#[ command( next_help_heading = "DEVELOPER" ) ]
253
218
pub struct DeveloperCliOptions {
254
219
/// Outputs Onefetch in a specific format
255
220
#[ arg( long, short, value_name = "FORMAT" , value_enum) ]
256
- #[ merge( skip) ]
257
221
pub output : Option < SerializationFormat > ,
258
222
/// If provided, outputs the completion file for given SHELL
259
223
#[ arg( long = "generate" , value_name = "SHELL" , value_enum) ]
260
- #[ merge( skip) ]
261
224
pub completion : Option < Shell > ,
262
225
}
263
226
264
- #[ derive( Clone , Debug , Args , PartialEq , Eq , Default , Merge ) ]
227
+ #[ derive( Clone , Debug , Args , PartialEq , Eq , Default ) ]
265
228
#[ command( next_help_heading = "OTHER" ) ]
266
229
pub struct OtherCliOptions {
267
230
/// Prints out supported languages
268
231
#[ arg( long, short) ]
269
- #[ merge( skip) ]
270
232
pub languages : bool ,
271
233
/// Prints out supported package managers
272
234
#[ arg( long, short) ]
273
- #[ merge( skip) ]
274
235
pub package_managers : bool ,
275
236
}
276
237
277
238
impl Default for CliOptions {
278
239
fn default ( ) -> CliOptions {
279
240
CliOptions {
280
241
input : PathBuf :: from ( "." ) ,
281
- config_path : None ,
282
242
info : InfoCliOptions :: default ( ) ,
283
243
text_formatting : TextForamttingCliOptions :: default ( ) ,
284
244
visuals : VisualsCliOptions :: default ( ) ,
@@ -342,15 +302,6 @@ impl Default for ImageCliOptions {
342
302
}
343
303
}
344
304
345
- pub fn overwrite < T > ( l : & mut T , r : T ) {
346
- * l = r;
347
- }
348
-
349
- pub fn overwrite_vec < T > ( l : & mut Vec < T > , mut r : Vec < T > ) {
350
- l. clear ( ) ;
351
- l. append ( & mut r) ;
352
- }
353
-
354
305
pub fn print_supported_languages ( ) -> Result < ( ) > {
355
306
for l in Language :: iter ( ) {
356
307
println ! ( "{l}" ) ;
0 commit comments