Skip to content

Commit 640057d

Browse files
authored
Merge pull request #168 from Sh3mm/patch-1
added a authors-number parameter
2 parents b4d4514 + 7edeefb commit 640057d

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

Diff for: src/info.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -302,14 +302,15 @@ impl Info {
302302
image_backend: Option<Box<dyn ImageBackend>>,
303303
no_merges: bool,
304304
color_blocks_flag: bool,
305+
author_nb: usize,
305306
) -> Result<Info> {
306307
let repo = Repository::discover(&dir).map_err(|_| Error::NotGitRepo)?;
307308
let workdir = repo.workdir().ok_or(Error::BareGitRepo)?;
308309
let workdir_str = workdir.to_str().unwrap();
309310

310311
let config = Info::get_configuration(&repo)?;
311312
let current_commit_info = Info::get_current_commit_info(&repo)?;
312-
let authors = Info::get_authors(workdir_str, no_merges, 3);
313+
let authors = Info::get_authors(workdir_str, no_merges, author_nb);
313314
let (git_v, git_user) = Info::get_git_info(workdir_str);
314315
let version = Info::get_version(workdir_str)?;
315316
let commits = Info::get_commits(workdir_str, no_merges)?;

Diff for: src/main.rs

+15
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,13 @@ Possible values: [{0}{1}{2}{3}{4}{5}{6}{7}{8}{9}{10}{11}{12}{13}{14}{15}]",
221221
.long("no-color-blocks")
222222
.help("Hide the color blocks"),
223223
)
224+
.arg(
225+
Arg::with_name("authors-number")
226+
.short("A")
227+
.long("authors-number")
228+
.takes_value(true)
229+
.help("Defines the number of authors to be shown"),
230+
)
224231
.get_matches();
225232

226233
if matches.is_present("languages") {
@@ -233,6 +240,7 @@ Possible values: [{0}{1}{2}{3}{4}{5}{6}{7}{8}{9}{10}{11}{12}{13}{14}{15}]",
233240
}
234241

235242
let dir = String::from(matches.value_of("directory").unwrap());
243+
236244
let custom_logo: Language = if let Some(ascii_language) = matches.value_of("ascii-language") {
237245
Language::from_str(&ascii_language.to_lowercase()).unwrap()
238246
} else {
@@ -304,6 +312,12 @@ Possible values: [{0}{1}{2}{3}{4}{5}{6}{7}{8}{9}{10}{11}{12}{13}{14}{15}]",
304312

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

315+
let author_number: usize = if let Some(value) = matches.value_of("authors-number") {
316+
usize::from_str(value).unwrap()
317+
} else {
318+
3
319+
};
320+
307321
let info = Info::new(
308322
&dir,
309323
custom_logo,
@@ -314,6 +328,7 @@ Possible values: [{0}{1}{2}{3}{4}{5}{6}{7}{8}{9}{10}{11}{12}{13}{14}{15}]",
314328
image_backend,
315329
no_merges,
316330
color_blocks_flag,
331+
author_number,
317332
)?;
318333

319334
print!("{}", info);

0 commit comments

Comments
 (0)