Skip to content

Commit 22b9c02

Browse files
committed
Fix documentation and field order
This adds/improves documentation in `Args` and fixes the documentation in other places. Also this orders the fields of `Args` so that the `Filter` related fields come last, since they are the least important, and take up a lot of space.
1 parent 055d571 commit 22b9c02

File tree

1 file changed

+27
-21
lines changed

1 file changed

+27
-21
lines changed

src/lib.rs

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,26 @@ use clap::{Parser, Subcommand};
88
#[derive(Parser, Debug)]
99
#[clap(version, about, long_about = None)]
1010
pub struct Args {
11+
/// Specifies how the program will read the git history.
1112
#[clap(subcommand)]
1213
input_method: InputMethod,
1314

1415
/// Always show the entire output.
1516
#[clap(short = 'v', long = "verbose")]
1617
is_verbose: bool,
1718

19+
/// Filter loc for certain file extension (e.g. `--file-extension cpp`). ORs if specified multiple times.
20+
#[clap(short, long)]
21+
file_extension: Vec<String>,
22+
23+
/// The time which may pass between two commits that still counts as working.
24+
#[clap(short, long, default_value_t = 3)]
25+
duration: u32,
26+
27+
/// An output file for the commits per day in CSV format.
28+
#[clap(short, long)]
29+
output: Option<PathBuf>,
30+
1831
/// Filter for certain author names. ORs if specified multiple times.
1932
#[clap(short, long)]
2033
author_contains: Vec<String>,
@@ -26,64 +39,57 @@ pub struct Args {
2639
/// Filter for certain author emails. ORs if specified multiple times.
2740
#[clap(short, long)]
2841
email_contains: Vec<String>,
42+
2943
/// Filter for certain author emails. ORs if specified multiple times.
3044
#[clap(long)]
3145
email_equals: Vec<String>,
3246

3347
/// Filter for certain commit hashes. ORs if specified multiple times.
3448
#[clap(short, long)]
3549
commit_contains: Vec<String>,
50+
3651
/// Filter for certain commit hashes. ORs if specified multiple times.
3752
#[clap(long)]
3853
commit_equals: Vec<String>,
3954

40-
/// Filter loc for certain file extension (e.g. `--file-extension cpp`). ORs if specified multiple times.
41-
#[clap(short, long)]
42-
file_extension: Vec<String>,
43-
4455
/// Filter for certain commit messages. ORs if specified multiple times.
4556
#[clap(short, long)]
4657
message_contains: Vec<String>,
58+
4759
/// Filter for certain commit messages. ORs if specified multiple times.
4860
#[clap(long)]
4961
message_equals: Vec<String>,
62+
5063
/// Filter for certain commit messages. ORs if specified multiple times.
5164
#[clap(short = 'l', long)]
5265
message_starts_with: Vec<String>,
53-
54-
/// The time which may pass between two commits that still counts as working.
55-
#[clap(short, long, default_value_t = 3)]
56-
duration: u32,
57-
58-
/// An output file for the commits per day in CSV format.
59-
#[clap(short, long)]
60-
output: Option<PathBuf>,
6166
}
6267

6368
impl Args {
64-
/// Get the input method specified by the user.
69+
/// Gets the input method specified by the user.
6570
#[must_use]
6671
pub fn input_method(&self) -> &InputMethod {
6772
&self.input_method
6873
}
6974

70-
/// Get the configured verbosity level of the program.
75+
/// Gets the configured verbosity level of the program.
7176
#[must_use]
7277
pub fn is_verbose(&self) -> bool {
7378
self.is_verbose
7479
}
7580

76-
/// Get the maximum duration between two commits considered spent working.
81+
/// Gets the maximum duration between two commits considered spent working.
7782
#[must_use]
7883
pub fn duration(&self) -> u32 {
7984
self.duration
8085
}
8186

82-
/// Takes the output path, specified by the user, out of `Args`.
87+
/// Moves the output path specified by the user out of `Args` by calling
88+
/// `Option::take`.
8389
///
8490
/// This method moves the specified path to the intended output file out of
85-
/// this struct. This should therefore only be called once, but saves an
86-
/// unnecessary clone.
91+
/// this struct. This should, hence, be called just once but prevents an
92+
/// obsolete clone.
8793
#[must_use]
8894
pub fn take_output(&mut self) -> Option<PathBuf> {
8995
self.output.take()
@@ -157,7 +163,7 @@ impl InputMethod {
157163

158164
/// The revealed filter creteria.
159165
///
160-
/// This data structure allows to filter the input commits by certain creteria.
166+
/// This data structure allows to filter the input commits by certain criteria.
161167
#[derive(Debug, Default)]
162168
pub struct Filter<'a> {
163169
/// A set of substrings to be contained by some authors' names.
@@ -524,7 +530,7 @@ impl LocDiff {
524530
&self.file
525531
}
526532

527-
/// Calculate the LOC diff.
533+
/// Calculates the LOC diff.
528534
pub fn loc(&self) -> i64 {
529535
if self.added.is_none() && self.removed.is_none() {
530536
0
@@ -533,7 +539,7 @@ impl LocDiff {
533539
}
534540
}
535541

536-
/// Extract the LOC diff information from the given line.
542+
/// Extracts the LOC diff information from the given line.
537543
pub fn parse(loc: &str) -> Result<Self, LocParseError> {
538544
let (added, remainder) = loc
539545
.split_once('\t')

0 commit comments

Comments
 (0)