Skip to content

Commit 50e3720

Browse files
committed
Revert "interesting"
This reverts commit c4fdd83.
1 parent c4fdd83 commit 50e3720

File tree

4 files changed

+37
-33
lines changed

4 files changed

+37
-33
lines changed

Cargo.lock

Lines changed: 17 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ members = ["ascii", "image", "manifest"]
1111
[workspace.dependencies]
1212
owo-colors = "4.2.0"
1313
anyhow = "1.0"
14-
clap = { version = "4.5.34", features = ["derive","string", ] }
14+
clap = { version = "4.5.34", features = ["derive"] }
1515
image = { version = "0.25.5", default-features = false, features = [
1616
"color_quant",
1717
"jpeg",

src/cli.rs

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
use crate::config::ConfigOptions;
21
use crate::info::langs::language::{Language, LanguageType};
32
use crate::info::utils::info_field::InfoType;
43
use crate::ui::printer::SerializationFormat;
54
use anyhow::Result;
6-
use clap::builder::{OsStr, PossibleValuesParser};
5+
use clap::builder::PossibleValuesParser;
76
use clap::builder::TypedValueParser as _;
87
use clap::{value_parser, Args, Command, Parser, ValueHint};
98
use clap_complete::{generate, Generator, Shell};
@@ -55,8 +54,7 @@ pub struct InfoCliOptions {
5554
num_args = 1..,
5655
hide_possible_values = true,
5756
value_enum,
58-
value_name = "FIELD",
59-
default_value = Vec::<String>::new().join(""),
57+
value_name = "FIELD"
6058
)]
6159
pub disabled_fields: Vec<InfoType>,
6260
/// Hides the title
@@ -221,10 +219,9 @@ pub struct VisualsCliOptions {
221219
#[command(next_help_heading = "CONFIG")]
222220
pub struct ConfigCliOptions {
223221
/// Path to the config file
224-
#[arg(long, value_hint = ValueHint::FilePath, default_value = ConfigCliOptions::default().config_path.into_os_string())]
225-
pub config_path: PathBuf,
222+
#[arg(long, value_hint = ValueHint::FilePath)]
223+
pub config_path: Option<PathBuf>,
226224
/// Creates a default config file
227-
///
228225
/// Writes to $XDG_CONFIG_HOME/onefetch/config.toml but can be overridden with --config-path
229226
#[arg(long)]
230227
pub generate_config: bool,
@@ -324,9 +321,7 @@ impl Default for ConfigCliOptions {
324321
fn default() -> Self {
325322
ConfigCliOptions {
326323
// Not sure about unwrap
327-
config_path: dirs::config_dir()
328-
.expect("Could not find $HOME!")
329-
.join("onefetch/config.toml"),
324+
config_path: Some(dirs::config_dir().expect("Could not find $HOME!").join("onefetch/config.toml")),
330325
generate_config: false,
331326
}
332327
}

src/main.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,8 @@ use human_panic::setup_panic;
66
use onefetch::cli::{self, CliOptions};
77
use onefetch::config::ConfigOptions;
88
use onefetch::info::build_info;
9-
use onefetch::info::utils::info_field::InfoType;
109
use onefetch::ui::printer::Printer;
1110
use std::io;
12-
use std::process::exit;
1311

1412
fn main() -> Result<()> {
1513
setup_panic!();
@@ -34,20 +32,22 @@ fn main() -> Result<()> {
3432
}
3533

3634
if cli_options.config.generate_config {
37-
return ConfigOptions::default().write(&cli_options.config.config_path);
35+
return ConfigOptions::default().write(
36+
&cli_options.config.config_path.unwrap_or(
37+
dirs::config_dir()
38+
.expect("Could not find config dir!")
39+
.join("onefetch/config.toml"),
40+
),
41+
);
3842
}
3943

40-
let config_options = ConfigOptions::read(&cli_options.config.config_path);
41-
42-
{
43-
let merged_disabled: Vec<InfoType> = config_options
44-
.disabled_fields
45-
.into_iter()
46-
.chain(cli_options.info.disabled_fields)
47-
.collect();
48-
println!("{:?}", merged_disabled);
49-
exit(0)
50-
}
44+
let config_options = ConfigOptions::read(
45+
&cli_options.config.config_path.as_ref().unwrap_or(
46+
&dirs::config_dir()
47+
.expect("Could not find config dir!")
48+
.join("onefetch/config.toml"),
49+
),
50+
);
5151

5252
let info = build_info(&cli_options, &config_options)?;
5353

0 commit comments

Comments
 (0)