Skip to content

Commit 5555a23

Browse files
committed
Revert "config: (de)serialization"
This reverts commit 3801cbf.
1 parent 8d79b15 commit 5555a23

File tree

7 files changed

+16
-113
lines changed

7 files changed

+16
-113
lines changed

src/cli.rs

Lines changed: 12 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ use clap::builder::PossibleValuesParser;
66
use clap::builder::TypedValueParser as _;
77
use clap::{value_parser, Args, Command, Parser, ValueHint};
88
use clap_complete::{generate, Generator, Shell};
9-
use merge::Merge;
109
use num_format::CustomFormat;
1110
use onefetch_image::ImageProtocol;
1211
use onefetch_manifest::ManifestType;
1312
use regex::Regex;
14-
use serde::{de::Visitor, Serializer, Deserialize, Serialize};
13+
use serde::Serialize;
14+
use merge::Merge;
1515
use std::env;
1616
use std::io;
1717
use std::path::PathBuf;
@@ -21,19 +21,17 @@ use strum::IntoEnumIterator;
2121
const COLOR_RESOLUTIONS: [&str; 5] = ["16", "32", "64", "128", "256"];
2222
pub 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)]
2626
pub 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")]
5654
pub 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")]
139137
pub 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")]
181178
pub 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")]
206202
pub 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")]
238234
pub 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")]
257253
pub 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")]
272266
pub 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)]
398390
pub 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)]
405397
pub 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-
}

src/config.rs

Lines changed: 0 additions & 52 deletions
This file was deleted.

src/info/langs/language.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use crate::info::utils::info_field::InfoField;
22
use owo_colors::OwoColorize;
3+
use serde::Serialize;
34
use tokei;
45

56
include!(concat!(env!("OUT_DIR"), "/language.rs"));

src/info/langs/language.tera

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ use owo_colors::{
55
use std::fmt;
66
use std::fmt::Write;
77
use strum::EnumIter;
8-
use serde::{Serialize, Deserialize};
98

109
pub struct Colors {
1110
basic_colors: Vec<DynColors>,
@@ -14,7 +13,7 @@ pub struct Colors {
1413

1514
const DEFAULT_CHIP_ICON: char = '\u{25CF}';
1615

17-
#[derive(Clone, PartialEq, Eq, Debug, clap::ValueEnum, Deserialize, Serialize)]
16+
#[derive(Clone, PartialEq, Eq, Debug, clap::ValueEnum)]
1817
pub enum LanguageType {
1918
Programming,
2019
Markup,

src/info/utils/info_field.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use crate::{info::utils::get_style, ui::text_colors::TextColors};
22
use owo_colors::OwoColorize;
3-
use serde::{Deserialize, Serialize};
43
use std::fmt;
54

65
#[typetag::serialize]
@@ -56,7 +55,7 @@ pub trait InfoField {
5655
}
5756
}
5857

59-
#[derive(Clone, clap::ValueEnum, Debug, Serialize, Deserialize, Eq, PartialEq)]
58+
#[derive(Clone, clap::ValueEnum, Debug, Eq, PartialEq)]
6059
pub enum InfoType {
6160
Project,
6261
Description,

src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
// Lib is present to allow for benchmarks and integration tests
22
pub mod cli;
3-
pub mod config;
43
pub mod info;
54
pub mod ui;

src/main.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ use anyhow::Result;
44
use clap::{CommandFactory, Parser};
55
use human_panic::setup_panic;
66
use onefetch::cli::{self, CliOptions};
7-
use onefetch::config;
87
use onefetch::info::build_info;
98
use onefetch::ui::printer::Printer;
109
use std::io;
@@ -15,7 +14,7 @@ fn main() -> Result<()> {
1514
#[cfg(windows)]
1615
enable_ansi_support::enable_ansi_support()?;
1716

18-
let cli_options = config::populate_cfg(cli::CliOptions::parse());
17+
let cli_options = cli::CliOptions::parse();
1918

2019
if cli_options.other.languages {
2120
return cli::print_supported_languages();

0 commit comments

Comments
 (0)