Skip to content

Commit

Permalink
simplify file structure
Browse files Browse the repository at this point in the history
  • Loading branch information
o2sh committed Jan 27, 2023
1 parent 5379ecd commit c7c30b4
Show file tree
Hide file tree
Showing 21 changed files with 64 additions and 66 deletions.
2 changes: 1 addition & 1 deletion src/cli.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::info::info_field::InfoType;
use crate::info::langs::language::{Language, LanguageType};
use crate::info::utils::info_field::InfoType;
use crate::ui::printer::SerializationFormat;
use anyhow::Result;
use clap::builder::PossibleValuesParser;
Expand Down
4 changes: 2 additions & 2 deletions src/info/repo/author.rs → src/info/author.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ use crate::{
cli::NumberSeparator,
info::{
format_number,
git::Commits,
info_field::{InfoField, InfoType},
utils::git::Commits,
utils::info_field::{InfoField, InfoType},
},
};
use git_repository as git;
Expand Down
4 changes: 2 additions & 2 deletions src/info/repo/commits.rs → src/info/commits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ use crate::{
cli::NumberSeparator,
info::{
format_number,
git::Commits,
info_field::{InfoField, InfoType},
utils::git::Commits,
utils::info_field::{InfoField, InfoType},
},
};

Expand Down
6 changes: 3 additions & 3 deletions src/info/repo/contributors.rs → src/info/contributors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ use crate::{
cli::NumberSeparator,
info::{
format_number,
git::Commits,
info_field::{InfoField, InfoType},
utils::git::Commits,
utils::info_field::{InfoField, InfoType},
},
};

Expand Down Expand Up @@ -58,7 +58,7 @@ mod test {

#[test]
fn test_display_contributors_info() {
use crate::info::git::Commits;
use crate::info::utils::git::Commits;
use git_repository::actor::Time;

let timestamp = Time::now_utc();
Expand Down
9 changes: 4 additions & 5 deletions src/info/repo/created.rs → src/info/created.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
use serde::Serialize;

use super::gitoxide_time_to_formatted_time;
use super::utils::gitoxide_time_to_formatted_time;
use crate::info::{
git::Commits,
info_field::{InfoField, InfoType},
utils::git::Commits,
utils::info_field::{InfoField, InfoType},
};
use serde::Serialize;

#[derive(Serialize)]
#[serde(rename_all = "camelCase")]
Expand Down
2 changes: 1 addition & 1 deletion src/info/repo/dependencies.rs → src/info/dependencies.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::{
cli::NumberSeparator,
info::{
format_number,
info_field::{InfoField, InfoType},
utils::info_field::{InfoField, InfoType},
},
};
use onefetch_manifest::Manifest;
Expand Down
2 changes: 1 addition & 1 deletion src/info/repo/description.rs → src/info/description.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::info::info_field::{InfoField, InfoType};
use crate::info::utils::info_field::{InfoField, InfoType};
use onefetch_manifest::Manifest;
use serde::Serialize;
use std::fmt::Write;
Expand Down
2 changes: 1 addition & 1 deletion src/info/repo/head.rs → src/info/head.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::info::info_field::{InfoField, InfoType};
use crate::info::utils::info_field::{InfoField, InfoType};
use anyhow::{Context, Result};
use git_repository::{reference::Category, Reference, Repository};
use serde::Serialize;
Expand Down
2 changes: 1 addition & 1 deletion src/info/langs/language.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::info::info_field::{InfoField, InfoType};
use crate::info::utils::info_field::{InfoField, InfoType};
use owo_colors::OwoColorize;
use serde::Serialize;
use tokei;
Expand Down
9 changes: 4 additions & 5 deletions src/info/repo/last_change.rs → src/info/last_change.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
use serde::Serialize;

use super::gitoxide_time_to_formatted_time;
use super::utils::gitoxide_time_to_formatted_time;
use crate::info::{
git::Commits,
info_field::{InfoField, InfoType},
utils::git::Commits,
utils::info_field::{InfoField, InfoType},
};
use serde::Serialize;

#[derive(Serialize)]
#[serde(rename_all = "camelCase")]
Expand Down
2 changes: 1 addition & 1 deletion src/info/repo/license.rs → src/info/license.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::info::info_field::{InfoField, InfoType};
use crate::info::utils::info_field::{InfoField, InfoType};
use anyhow::{bail, Result};
use askalono::{Store, TextData};
use onefetch_manifest::Manifest;
Expand Down
2 changes: 1 addition & 1 deletion src/info/repo/loc.rs → src/info/loc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::{
cli::NumberSeparator,
info::{
format_number,
info_field::{InfoField, InfoType},
utils::info_field::{InfoField, InfoType},
},
};

Expand Down
55 changes: 34 additions & 21 deletions src/info/mod.rs
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
use self::git::Commits;
use self::info_field::{InfoField, InfoType};
use self::author::AuthorsInfo;
use self::commits::CommitsInfo;
use self::contributors::ContributorsInfo;
use self::created::CreatedInfo;
use self::dependencies::DependenciesInfo;
use self::description::DescriptionInfo;
use self::head::HeadInfo;
use self::langs::language::Language;
use self::langs::language::LanguagesInfo;
use self::repo::author::AuthorsInfo;
use self::repo::commits::CommitsInfo;
use self::repo::contributors::ContributorsInfo;
use self::repo::created::CreatedInfo;
use self::repo::dependencies::DependenciesInfo;
use self::repo::description::DescriptionInfo;
use self::repo::head::HeadInfo;
use self::repo::last_change::LastChangeInfo;
use self::repo::license::LicenseInfo;
use self::repo::loc::LocInfo;
use self::repo::pending::PendingInfo;
use self::repo::project::ProjectInfo;
use self::repo::size::SizeInfo;
use self::repo::url::UrlInfo;
use self::repo::version::VersionInfo;
use self::last_change::LastChangeInfo;
use self::license::LicenseInfo;
use self::loc::LocInfo;
use self::pending::PendingInfo;
use self::project::ProjectInfo;
use self::size::SizeInfo;
use self::title::Title;
use self::url::UrlInfo;
use self::utils::git::Commits;
use self::utils::info_field::{InfoField, InfoType};
use self::version::VersionInfo;
use crate::cli::{is_truecolor_terminal, Config, NumberSeparator, When};
use crate::ui::get_ascii_colors;
use crate::ui::text_colors::TextColors;
Expand All @@ -28,11 +28,24 @@ use owo_colors::{DynColors, OwoColorize, Style};
use serde::Serialize;
use std::path::Path;

mod git;
pub mod info_field;
mod author;
mod commits;
mod contributors;
mod created;
mod dependencies;
mod description;
mod head;
pub mod langs;
mod repo;
pub mod title;
mod last_change;
mod license;
mod loc;
mod pending;
mod project;
mod size;
mod title;
mod url;
pub mod utils;
mod version;

#[derive(Serialize)]
#[serde(rename_all = "camelCase")]
Expand Down
2 changes: 1 addition & 1 deletion src/info/repo/pending.rs → src/info/pending.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::info::info_field::{InfoField, InfoType};
use crate::info::utils::info_field::{InfoField, InfoType};
use anyhow::Result;
use git2::{Status, StatusOptions, StatusShow};
use git_repository::Repository;
Expand Down
2 changes: 1 addition & 1 deletion src/info/repo/project.rs → src/info/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::{
cli::NumberSeparator,
info::{
format_number,
info_field::{InfoField, InfoType},
utils::info_field::{InfoField, InfoType},
},
};
use anyhow::Result;
Expand Down
2 changes: 1 addition & 1 deletion src/info/repo/size.rs → src/info/size.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::{
cli::NumberSeparator,
info::{
format_number,
info_field::{InfoField, InfoType},
utils::info_field::{InfoField, InfoType},
},
};
use byte_unit::Byte;
Expand Down
2 changes: 1 addition & 1 deletion src/info/repo/url.rs → src/info/url.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::info::info_field::{InfoField, InfoType};
use crate::info::utils::info_field::{InfoField, InfoType};
use anyhow::Result;
use git_repository::Repository;
use serde::Serialize;
Expand Down
2 changes: 1 addition & 1 deletion src/info/git.rs → src/info/utils/git.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use super::repo::author::Author;
use crate::cli::{MyRegex, NumberSeparator};
use crate::info::author::Author;
use anyhow::Result;
use git::bstr::BString;
use git_repository as git;
Expand Down
File renamed without changes.
17 changes: 2 additions & 15 deletions src/info/repo/mod.rs → src/info/utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,8 @@ use git_repository::actor::Time;
use time::{format_description::well_known::Rfc3339, OffsetDateTime};
use time_humanize::HumanTime;

pub mod author;
pub mod commits;
pub mod contributors;
pub mod created;
pub mod dependencies;
pub mod description;
pub mod head;
pub mod last_change;
pub mod license;
pub mod loc;
pub mod pending;
pub mod project;
pub mod size;
pub mod url;
pub mod version;
pub mod git;
pub mod info_field;

pub fn gitoxide_time_to_formatted_time(time: Time, iso_time: bool) -> String {
if iso_time {
Expand Down
2 changes: 1 addition & 1 deletion src/info/repo/version.rs → src/info/version.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::info::info_field::{InfoField, InfoType};
use crate::info::utils::info_field::{InfoField, InfoType};
use anyhow::Result;
use git_repository::Repository;
use onefetch_manifest::Manifest;
Expand Down

0 comments on commit c7c30b4

Please sign in to comment.