Skip to content

Commit

Permalink
rename format flag to output and other changes
Browse files Browse the repository at this point in the history
  • Loading branch information
o2sh committed Dec 15, 2020
1 parent 80424f4 commit 667897e
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 202 deletions.
140 changes: 0 additions & 140 deletions CHANGELOG.md

This file was deleted.

11 changes: 5 additions & 6 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,16 @@ fn run() -> Result<()> {
if !repo::is_valid(&config.repo_path)? {
return Err("please run onefetch inside of a non-bare git repository".into());
}

let format = config.format.clone();
let format = config.output.clone();

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

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

match format.as_str() {
"human" => printer.print()?,
"json" => printer.print_json()?,
_ => printer.print()?,
if format.is_some() {
printer.print_json()?
} else {
printer.print()?
}

Ok(())
Expand Down
40 changes: 20 additions & 20 deletions src/onefetch/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pub struct Cli {
pub excluded: Vec<String>,
pub print_languages: bool,
pub print_package_managers: bool,
pub format: String,
pub output: Option<String>,
pub true_color: bool,
pub art_off: bool,
pub text_colors: Vec<String>,
Expand Down Expand Up @@ -59,20 +59,29 @@ impl Cli {
.hide_default_value(true)
.help("Run as if onefetch was started in <input> instead of the current working directory.",
))
.arg(
Arg::with_name("output")
.short("o")
.long("output")
.help("Outputs Onefetch in a specific format (json).")
.takes_value(true)
.hide_possible_values(false)
.possible_values(&["json"])
)
.arg(
Arg::with_name("languages")
.short("l")
.long("languages")
.help("Prints out supported languages."),
.short("l")
.long("languages")
.help("Prints out supported languages."),
)
.arg(
Arg::with_name("package-managers")
.short("p")
.long("package-managers")
.short("p")
.long("package-managers")
.help("Prints out supported package managers."),
)
.arg(
Arg::with_name("show-logo")
)
.arg(
Arg::with_name("show-logo")
.long("show-logo")
.value_name("WHEN")
.takes_value(true)
Expand Down Expand Up @@ -229,15 +238,6 @@ impl Cli {
.takes_value(true)
.help("Ignore all files & directories matching EXCLUDE."),
)
.arg(
Arg::with_name("format")
.short("f")
.long("format")
.help("Select a output format.")
.takes_value(true)
.default_value("human")
.possible_values(&["human", "json"])
)
.get_matches();

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

let fields_to_hide: Vec<String> = if let Some(values) = matches.values_of("disable-fields")
{
Expand Down Expand Up @@ -342,7 +342,7 @@ impl Cli {
excluded,
print_languages,
print_package_managers,
format,
output,
true_color,
text_colors,
art_off,
Expand Down
1 change: 0 additions & 1 deletion src/onefetch/info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,6 @@ impl Serialize for Info {
state.serialize_field("filesCount", &self.file_count)?;
state.serialize_field("license", &self.license)?;
state.serialize_field("dominantLanguage", &self.dominant_language)?;
state.serialize_field("textColors", &self.text_colors)?;
state.end()
}
}
1 change: 0 additions & 1 deletion src/onefetch/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,5 @@ mod language;
mod license;
pub mod printer;
pub mod repo;
mod serializer;
mod text_color;
mod utils;
23 changes: 0 additions & 23 deletions src/onefetch/serializer.rs

This file was deleted.

12 changes: 1 addition & 11 deletions src/onefetch/text_color.rs
Original file line number Diff line number Diff line change
@@ -1,21 +1,11 @@
use {
crate::onefetch::serializer::ColorDef, crate::onefetch::utils::num_to_color, colored::Color,
serde::Serialize,
};
use {crate::onefetch::utils::num_to_color, colored::Color};

#[derive(Serialize)]
pub struct TextColor {
#[serde(with = "ColorDef")]
pub title: Color,
#[serde(with = "ColorDef")]
pub tilde: Color,
#[serde(with = "ColorDef")]
pub underline: Color,
#[serde(with = "ColorDef")]
pub subtitle: Color,
#[serde(with = "ColorDef")]
pub colon: Color,
#[serde(with = "ColorDef")]
pub info: Color,
}

Expand Down

0 comments on commit 667897e

Please sign in to comment.