Skip to content

added a authors-number parameter #168

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -293,14 +293,15 @@ impl Info {
image_backend: Option<Box<dyn ImageBackend>>,
no_merges: bool,
color_blocks_flag: bool,
author_nb: usize,
) -> Result<Info> {
let repo = Repository::discover(&dir).map_err(|_| Error::NotGitRepo)?;
let workdir = repo.workdir().ok_or(Error::BareGitRepo)?;
let workdir_str = workdir.to_str().unwrap();

let config = Info::get_configuration(&repo)?;
let current_commit_info = Info::get_current_commit_info(&repo)?;
let authors = Info::get_authors(workdir_str, no_merges, 3);
let authors = Info::get_authors(workdir_str, no_merges, author_nb);
let (git_v, git_user) = Info::get_git_info(workdir_str);
let version = Info::get_version(workdir_str)?;
let commits = Info::get_commits(workdir_str, no_merges)?;
Expand Down
15 changes: 15 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,13 @@ Possible values: [{0}{1}{2}{3}{4}{5}{6}{7}{8}{9}{10}{11}{12}{13}{14}{15}]",
.long("no-color-blocks")
.help("Hide the color blocks"),
)
.arg(
Arg::with_name("authors-number")
.short("A")
.long("authors-number")
.takes_value(true)
.help("Defines the number of authors to be shown"),
)
.get_matches();

if matches.is_present("languages") {
Expand All @@ -231,6 +238,7 @@ Possible values: [{0}{1}{2}{3}{4}{5}{6}{7}{8}{9}{10}{11}{12}{13}{14}{15}]",
}

let dir = String::from(matches.value_of("directory").unwrap());

let custom_logo: Language = if let Some(ascii_language) = matches.value_of("ascii-language") {
Language::from_str(&ascii_language.to_lowercase()).unwrap()
} else {
Expand Down Expand Up @@ -301,6 +309,12 @@ Possible values: [{0}{1}{2}{3}{4}{5}{6}{7}{8}{9}{10}{11}{12}{13}{14}{15}]",

let color_blocks_flag = matches.is_present("no-color-blocks");

let author_number: usize = if let Some(value) = matches.value_of("authors-number") {
usize::from_str(value).unwrap()
} else {
3
};

let info = Info::new(
&dir,
custom_logo,
Expand All @@ -311,6 +325,7 @@ Possible values: [{0}{1}{2}{3}{4}{5}{6}{7}{8}{9}{10}{11}{12}{13}{14}{15}]",
image_backend,
no_merges,
color_blocks_flag,
author_number,
)?;

print!("{}", info);
Expand Down