Skip to content

Commit 5663f7f

Browse files
committed
Revert "cli: add merge strategies"
This reverts commit 1c5515e.
1 parent 5555a23 commit 5663f7f

File tree

1 file changed

+8
-57
lines changed

1 file changed

+8
-57
lines changed

src/cli.rs

Lines changed: 8 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ use onefetch_image::ImageProtocol;
1111
use onefetch_manifest::ManifestType;
1212
use regex::Regex;
1313
use serde::Serialize;
14-
use merge::Merge;
1514
use std::env;
1615
use std::io;
1716
use std::path::PathBuf;
@@ -21,18 +20,12 @@ use strum::IntoEnumIterator;
2120
const COLOR_RESOLUTIONS: [&str; 5] = ["16", "32", "64", "128", "256"];
2221
pub const NO_BOTS_DEFAULT_REGEX_PATTERN: &str = r"(?:-|\s)[Bb]ot$|\[[Bb]ot\]";
2322

24-
#[derive(Clone, Debug, Parser, PartialEq, Eq, Merge)]
23+
#[derive(Clone, Debug, Parser, PartialEq, Eq)]
2524
#[command(version, about)]
2625
pub struct CliOptions {
2726
/// Run as if onefetch was started in <input> instead of the current working directory
2827
#[arg(default_value = ".", hide_default_value = true, value_hint = ValueHint::DirPath)]
29-
#[merge(skip)]
3028
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>,
3629
#[command(flatten)]
3730
pub info: InfoCliOptions,
3831
#[command(flatten)]
@@ -49,7 +42,7 @@ pub struct CliOptions {
4942
pub other: OtherCliOptions,
5043
}
5144

52-
#[derive(Clone, Debug, Args, PartialEq, Eq, Merge)]
45+
#[derive(Clone, Debug, Args, PartialEq, Eq)]
5346
#[command(next_help_heading = "INFO")]
5447
pub struct InfoCliOptions {
5548
/// Allows you to disable FIELD(s) from appearing in the output
@@ -61,34 +54,27 @@ pub struct InfoCliOptions {
6154
value_enum,
6255
value_name = "FIELD"
6356
)]
64-
#[merge(strategy = overwrite_vec)]
6557
pub disabled_fields: Vec<InfoType>,
6658
/// Hides the title
6759
#[arg(long)]
68-
#[merge(strategy = merge::bool::overwrite_false)]
6960
pub no_title: bool,
7061
/// Maximum NUM of authors to be shown
7162
#[arg(long, default_value_t = 3usize, value_name = "NUM")]
72-
#[merge(strategy = overwrite)]
7363
pub number_of_authors: usize,
7464
/// Maximum NUM of languages to be shown
7565
#[arg(long, default_value_t = 6usize, value_name = "NUM")]
76-
#[merge(strategy = overwrite)]
7766
pub number_of_languages: usize,
7867
/// Maximum NUM of file churns to be shown
7968
#[arg(long, default_value_t = 3usize, value_name = "NUM")]
80-
#[merge(strategy = overwrite)]
8169
pub number_of_file_churns: usize,
8270
/// Minimum NUM of commits from HEAD used to compute the churn summary
8371
///
8472
/// By default, the actual value is non-deterministic due to time-based computation
8573
/// and will be displayed under the info title "Churn (NUM)"
8674
#[arg(long, value_name = "NUM")]
87-
#[merge(strategy = overwrite)]
8875
pub churn_pool_size: Option<usize>,
8976
/// Ignore all files & directories matching EXCLUDE
9077
#[arg(long, short, num_args = 1..)]
91-
#[merge(strategy = overwrite_vec)]
9278
pub exclude: Vec<String>,
9379
/// Exclude [bot] commits. Use <REGEX> to override the default pattern
9480
#[arg(
@@ -98,27 +84,21 @@ pub struct InfoCliOptions {
9884
default_missing_value = NO_BOTS_DEFAULT_REGEX_PATTERN,
9985
value_name = "REGEX"
10086
)]
101-
#[merge(strategy = overwrite)]
10287
pub no_bots: Option<MyRegex>,
10388
/// Ignores merge commits
10489
#[arg(long)]
105-
#[merge(strategy = merge::bool::overwrite_false)]
10690
pub no_merges: bool,
10791
/// Show the email address of each author
10892
#[arg(long, short = 'E')]
109-
#[merge(strategy = merge::bool::overwrite_false)]
11093
pub email: bool,
11194
/// Display repository URL as HTTP
11295
#[arg(long)]
113-
#[merge(strategy = merge::bool::overwrite_false)]
11496
pub http_url: bool,
11597
/// Hide token in repository URL
11698
#[arg(long)]
117-
#[merge(strategy = merge::bool::overwrite_false)]
11899
pub hide_token: bool,
119100
/// Count hidden files and directories
120101
#[arg(long)]
121-
#[merge(strategy = merge::bool::overwrite_false)]
122102
pub include_hidden: bool,
123103
/// Filters output by language type
124104
#[arg(
@@ -128,11 +108,10 @@ pub struct InfoCliOptions {
128108
short = 'T',
129109
value_enum,
130110
)]
131-
#[merge(strategy = overwrite_vec)]
132111
pub r#type: Vec<LanguageType>,
133112
}
134113

135-
#[derive(Clone, Debug, Args, PartialEq, Eq, Merge)]
114+
#[derive(Clone, Debug, Args, PartialEq, Eq)]
136115
#[command(next_help_heading = "ASCII")]
137116
pub struct AsciiCliOptions {
138117
/// Takes a non-empty STRING as input to replace the ASCII logo
@@ -143,7 +122,6 @@ pub struct AsciiCliOptions {
143122
///
144123
/// '--ascii-input "$(fortune | cowsay -W 25)"'
145124
#[arg(long, value_name = "STRING", value_hint = ValueHint::CommandString)]
146-
#[merge(strategy = overwrite)]
147125
pub ascii_input: Option<String>,
148126
/// Colors (X X X...) to print the ascii art
149127
#[arg(
@@ -153,7 +131,6 @@ pub struct AsciiCliOptions {
153131
short = 'c',
154132
value_parser = value_parser!(u8).range(..16),
155133
)]
156-
#[merge(strategy = overwrite_vec)]
157134
pub ascii_colors: Vec<u8>,
158135
/// Which LANGUAGE's ascii art to print
159136
#[arg(
@@ -163,26 +140,22 @@ pub struct AsciiCliOptions {
163140
value_enum,
164141
hide_possible_values = true
165142
)]
166-
#[merge(skip)]
167143
pub ascii_language: Option<Language>,
168144
/// Specify when to use true color
169145
///
170146
/// If set to auto: true color will be enabled if supported by the terminal
171147
#[arg(long, default_value = "auto", value_name = "WHEN", value_enum)]
172-
#[merge(strategy = overwrite)]
173148
pub true_color: When,
174149
}
175150

176-
#[derive(Clone, Debug, Args, PartialEq, Eq, Merge)]
151+
#[derive(Clone, Debug, Args, PartialEq, Eq)]
177152
#[command(next_help_heading = "IMAGE")]
178153
pub struct ImageCliOptions {
179154
/// Path to the IMAGE file
180155
#[arg(long, short, value_hint = ValueHint::FilePath)]
181-
#[merge(strategy = overwrite)]
182156
pub image: Option<PathBuf>,
183157
/// Which image PROTOCOL to use
184158
#[arg(long, value_enum, requires = "image", value_name = "PROTOCOL")]
185-
#[merge(skip)]
186159
pub image_protocol: Option<ImageProtocol>,
187160
/// VALUE of color resolution to use with SIXEL backend
188161
#[arg(
@@ -193,11 +166,10 @@ pub struct ImageCliOptions {
193166
value_parser = PossibleValuesParser::new(COLOR_RESOLUTIONS)
194167
.map(|s| s.parse::<usize>().unwrap())
195168
)]
196-
#[merge(strategy = overwrite)]
197169
pub color_resolution: usize,
198170
}
199171

200-
#[derive(Clone, Debug, Args, PartialEq, Eq, Merge)]
172+
#[derive(Clone, Debug, Args, PartialEq, Eq)]
201173
#[command(next_help_heading = "TEXT FORMATTING")]
202174
pub struct TextForamttingCliOptions {
203175
/// Changes the text colors (X X X...)
@@ -214,71 +186,59 @@ pub struct TextForamttingCliOptions {
214186
value_parser = value_parser!(u8).range(..16),
215187
num_args = 1..=6
216188
)]
217-
#[merge(strategy = overwrite_vec)]
218189
pub text_colors: Vec<u8>,
219190
/// Use ISO 8601 formatted timestamps
220191
#[arg(long, short = 'z')]
221-
#[merge(strategy = merge::bool::overwrite_false)]
222192
pub iso_time: bool,
223193
/// Which thousands SEPARATOR to use
224194
#[arg(long, value_name = "SEPARATOR", default_value = "plain", value_enum)]
225-
#[merge(strategy = overwrite)]
226195
pub number_separator: NumberSeparator,
227196
/// Turns off bold formatting
228197
#[arg(long)]
229-
#[merge(strategy = merge::bool::overwrite_false)]
230198
pub no_bold: bool,
231199
}
232-
#[derive(Clone, Debug, Args, PartialEq, Eq, Default, Merge)]
200+
#[derive(Clone, Debug, Args, PartialEq, Eq, Default)]
233201
#[command(next_help_heading = "VISUALS")]
234202
pub struct VisualsCliOptions {
235203
/// Hides the color palette
236204
#[arg(long)]
237-
#[merge(strategy = merge::bool::overwrite_false)]
238205
pub no_color_palette: bool,
239206
/// Hides the ascii art or image if provided
240207
#[arg(long)]
241-
#[merge(strategy = merge::bool::overwrite_false)]
242208
pub no_art: bool,
243209
/// Use Nerd Font icons
244210
///
245211
/// Replaces language chips with Nerd Font icons
246212
#[arg(long)]
247-
#[merge(strategy = merge::bool::overwrite_false)]
248213
pub nerd_fonts: bool,
249214
}
250215

251-
#[derive(Clone, Debug, Args, PartialEq, Eq, Default, Merge)]
216+
#[derive(Clone, Debug, Args, PartialEq, Eq, Default)]
252217
#[command(next_help_heading = "DEVELOPER")]
253218
pub struct DeveloperCliOptions {
254219
/// Outputs Onefetch in a specific format
255220
#[arg(long, short, value_name = "FORMAT", value_enum)]
256-
#[merge(skip)]
257221
pub output: Option<SerializationFormat>,
258222
/// If provided, outputs the completion file for given SHELL
259223
#[arg(long = "generate", value_name = "SHELL", value_enum)]
260-
#[merge(skip)]
261224
pub completion: Option<Shell>,
262225
}
263226

264-
#[derive(Clone, Debug, Args, PartialEq, Eq, Default, Merge)]
227+
#[derive(Clone, Debug, Args, PartialEq, Eq, Default)]
265228
#[command(next_help_heading = "OTHER")]
266229
pub struct OtherCliOptions {
267230
/// Prints out supported languages
268231
#[arg(long, short)]
269-
#[merge(skip)]
270232
pub languages: bool,
271233
/// Prints out supported package managers
272234
#[arg(long, short)]
273-
#[merge(skip)]
274235
pub package_managers: bool,
275236
}
276237

277238
impl Default for CliOptions {
278239
fn default() -> CliOptions {
279240
CliOptions {
280241
input: PathBuf::from("."),
281-
config_path: None,
282242
info: InfoCliOptions::default(),
283243
text_formatting: TextForamttingCliOptions::default(),
284244
visuals: VisualsCliOptions::default(),
@@ -342,15 +302,6 @@ impl Default for ImageCliOptions {
342302
}
343303
}
344304

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-
354305
pub fn print_supported_languages() -> Result<()> {
355306
for l in Language::iter() {
356307
println!("{l}");

0 commit comments

Comments
 (0)