Skip to content

Commit 667897e

Browse files
committed
rename format flag to output and other changes
1 parent 80424f4 commit 667897e

File tree

7 files changed

+26
-202
lines changed

7 files changed

+26
-202
lines changed

CHANGELOG.md

-140
This file was deleted.

src/main.rs

+5-6
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,16 @@ fn run() -> Result<()> {
2525
if !repo::is_valid(&config.repo_path)? {
2626
return Err("please run onefetch inside of a non-bare git repository".into());
2727
}
28-
29-
let format = config.format.clone();
28+
let format = config.output.clone();
3029

3130
let info = info::Info::new(config)?;
3231

3332
let mut printer = Printer::new(io::BufWriter::new(io::stdout()), info);
3433

35-
match format.as_str() {
36-
"human" => printer.print()?,
37-
"json" => printer.print_json()?,
38-
_ => printer.print()?,
34+
if format.is_some() {
35+
printer.print_json()?
36+
} else {
37+
printer.print()?
3938
}
4039

4140
Ok(())

src/onefetch/cli.rs

+20-20
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ pub struct Cli {
3131
pub excluded: Vec<String>,
3232
pub print_languages: bool,
3333
pub print_package_managers: bool,
34-
pub format: String,
34+
pub output: Option<String>,
3535
pub true_color: bool,
3636
pub art_off: bool,
3737
pub text_colors: Vec<String>,
@@ -59,20 +59,29 @@ impl Cli {
5959
.hide_default_value(true)
6060
.help("Run as if onefetch was started in <input> instead of the current working directory.",
6161
))
62+
.arg(
63+
Arg::with_name("output")
64+
.short("o")
65+
.long("output")
66+
.help("Outputs Onefetch in a specific format (json).")
67+
.takes_value(true)
68+
.hide_possible_values(false)
69+
.possible_values(&["json"])
70+
)
6271
.arg(
6372
Arg::with_name("languages")
64-
.short("l")
65-
.long("languages")
66-
.help("Prints out supported languages."),
73+
.short("l")
74+
.long("languages")
75+
.help("Prints out supported languages."),
6776
)
6877
.arg(
6978
Arg::with_name("package-managers")
70-
.short("p")
71-
.long("package-managers")
79+
.short("p")
80+
.long("package-managers")
7281
.help("Prints out supported package managers."),
73-
)
74-
.arg(
75-
Arg::with_name("show-logo")
82+
)
83+
.arg(
84+
Arg::with_name("show-logo")
7685
.long("show-logo")
7786
.value_name("WHEN")
7887
.takes_value(true)
@@ -229,15 +238,6 @@ impl Cli {
229238
.takes_value(true)
230239
.help("Ignore all files & directories matching EXCLUDE."),
231240
)
232-
.arg(
233-
Arg::with_name("format")
234-
.short("f")
235-
.long("format")
236-
.help("Select a output format.")
237-
.takes_value(true)
238-
.default_value("human")
239-
.possible_values(&["human", "json"])
240-
)
241241
.get_matches();
242242

243243
let true_color = cli_utils::is_truecolor_terminal();
@@ -246,7 +246,7 @@ impl Cli {
246246
let no_color_palette = matches.is_present("no-color-palette");
247247
let print_languages = matches.is_present("languages");
248248
let print_package_managers = matches.is_present("package-managers");
249-
let format = matches.value_of("format").map(String::from).unwrap();
249+
let output = matches.value_of("output").map(String::from);
250250

251251
let fields_to_hide: Vec<String> = if let Some(values) = matches.values_of("disable-fields")
252252
{
@@ -342,7 +342,7 @@ impl Cli {
342342
excluded,
343343
print_languages,
344344
print_package_managers,
345-
format,
345+
output,
346346
true_color,
347347
text_colors,
348348
art_off,

src/onefetch/info.rs

-1
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,6 @@ impl Serialize for Info {
426426
state.serialize_field("filesCount", &self.file_count)?;
427427
state.serialize_field("license", &self.license)?;
428428
state.serialize_field("dominantLanguage", &self.dominant_language)?;
429-
state.serialize_field("textColors", &self.text_colors)?;
430429
state.end()
431430
}
432431
}

src/onefetch/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,5 @@ mod language;
1111
mod license;
1212
pub mod printer;
1313
pub mod repo;
14-
mod serializer;
1514
mod text_color;
1615
mod utils;

src/onefetch/serializer.rs

-23
This file was deleted.

src/onefetch/text_color.rs

+1-11
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,11 @@
1-
use {
2-
crate::onefetch::serializer::ColorDef, crate::onefetch::utils::num_to_color, colored::Color,
3-
serde::Serialize,
4-
};
1+
use {crate::onefetch::utils::num_to_color, colored::Color};
52

6-
#[derive(Serialize)]
73
pub struct TextColor {
8-
#[serde(with = "ColorDef")]
94
pub title: Color,
10-
#[serde(with = "ColorDef")]
115
pub tilde: Color,
12-
#[serde(with = "ColorDef")]
136
pub underline: Color,
14-
#[serde(with = "ColorDef")]
157
pub subtitle: Color,
16-
#[serde(with = "ColorDef")]
178
pub colon: Color,
18-
#[serde(with = "ColorDef")]
199
pub info: Color,
2010
}
2111

0 commit comments

Comments
 (0)